我一直在用Corona SDK制作游戏。我正在尝试在屏幕中间显示图像,但它显示在随机位置。我想要显示的图片是circle.png。如果可以,请你帮助我。
以下是代码:
local 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
答案 0 :(得分:1)
试试这个,
<div id="cuadrado"></div>
答案 1 :(得分:0)
试一试。
local cirlce = display.newImageRect("images/gamescreen/circle.png", 184, 179)
cirlce.x = centerX
cirlce.y = centerY