gpt4 book ai didi

image - 在 Corona sdk 中显示图像

转载 作者:行者123 更新时间:2023-12-02 03:25:00 25 4
gpt4 key购买 nike

我一直在使用 Corona SDK 制作游戏。我正在尝试在屏幕中间显示图像,但它显示在随机位置。我要显示的图像是 circle.png。如果可以,请你帮助我。

代码如下:

本地 composer = require( "composer")

strong textlocal scene = composer.newScene()
local widget = require "widget"
widget.setTheme ("widget_theme_ios")



local score
local scoreEarn = 1

local lives = {}
local livesCount = 1

local balls = {}

local ballsCount = 0

local ballsSendSpeed = 65

local ballsTravelSpeed = 3500

local ballsIncrementSpeed = 1.5

local ballsMaxSendSpeed = 30

local timer_Counter

local onGameOver, gameOverBox, gameoverBackground, btn_returnToMenu

-- -------------------------------------------------------------------------------


-- "scene:create()"
function scene:create( event )

local sceneGroup = self.view

-- Initialize the scene here.
-- Example: add display objects to "sceneGroup", add touch listeners, etc.
local function ballTap(event)

end

local function ballDrag()

end

local function ballSend ()

end

local function ballsCollision ()

end

local function onCollision (event)

end

local function circleDamage ()

end

function gameOver ()

end

local background = display.newImageRect(sceneGroup, "images/gamescreen/background.png", 1600, 1200)
background.x = _CX
background.y = _CY

local cirlce = display.newImageRect(sceneGroup, "images/gamescreen/circle.png", 184, 179)
cirlce.x = _CX
cirlce.y = _CY





end


-- "scene:show()"
function scene:show( event )

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
-- Called when the scene is still off screen (but is about to come on screen).
elseif ( phase == "did" ) then
-- Called when the scene is now on screen.
-- Insert code here to make the scene come alive.
-- Example: start timers, begin animation, play audio, etc.
end
end


-- "scene:hide()"
function scene:hide( event )

local sceneGroup = self.view
local phase = event.phase

if ( phase == "will" ) then
-- Called when the scene is on screen (but is about to go off screen).
-- Insert code here to "pause" the scene.
-- Example: stop timers, stop animation, stop audio, etc.
elseif ( phase == "did" ) then
-- Called immediately after scene goes off screen.
end
end


-- "scene:destroy()"
function scene:destroy( event )

local sceneGroup = self.view

-- Called prior to the removal of scene's view ("sceneGroup").
-- Insert code here to clean up the scene.
-- Example: remove display objects, save state, etc.
end


-- -------------------------------------------------------------------------------

-- Listener setup
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )

-- -------------------------------------------------------------------------------

return scene

最佳答案

试试这个,

 local cirlce = display.newImageRect(sceneGroup, "images/gamescreen/circle.png", 184, 179)
cirlce.x = display.viewableContentWidth/2
cirlce.y = display.viewableContentHeight/2

关于image - 在 Corona sdk 中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30893505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com