hello,
i have recently started on this project (https://docs.coronalabs.com/guide/programming/02/index.html)
but instead of my ship asteroid 3 is on screen. how can I swap asteroid 3 and my ship?
code:
local physics = require( “physics” )
physics.start()
physics.setGravity( 0, 0 )
– Seed the random number generator
math.randomseed( os.time() )
– Configure image sheet
local sheetOptions =
{
frames =
{
{ – 1) ship
x = 0,
y = 302,
width = 150,
height = 150
},
{ – 2) asteroid 1
x = 0,
y = 0,
width = 150,
height = 150
},
{ – 3) asteroid 2
x = 0,
y = 151,
width = 150,
height = 150
},
{ – 4) asteroid 3
x = 151,
y = 0,
width = 150,
height = 150
},
{ – 5) laser
x = 151,
y = 151,
width = 150,
height = 150
},
},
}
local objectSheet = graphics.newImageSheet( “gameObjects.png”, sheetOptions )
– Initialize variables
local lives = 3
local score = 0
local died = false
local asteroidsTable = {}
local ship
local gameLoopTimer
local livesText
local scoreText
– Set up display groups
local backGroup = display.newGroup() – Display group for the background image
local mainGroup = display.newGroup() – Display group for the ship, asteroids, lasers, etc.
local uiGroup = display.newGroup() – Display group for UI objects like the score
– Load the background
local background = display.newImageRect( backGroup, “background.png”, 800, 1400 )
background.x = display.contentCenterX
background.y = display.contentCenterY
ship = display.newImageRect( mainGroup, objectSheet, 4, 98, 79 )
ship.x = display.contentCenterX
ship.y = display.contentHeight - 100
physics.addBody( ship, { radius=30, isSensor=true } )
ship.myName = “ship”
– Display lives and score
livesText = display.newText( uiGroup, "Lives: " … lives, 200, 80, native.systemFont, 36 )
scoreText = display.newText( uiGroup, "Score: " … score, 400, 80, native.systemFont, 36 )