Beruflich Dokumente
Kultur Dokumente
lua
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------[[
This example expands on the last
]]
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------- These functions acts as a factory to make explosion sprites and remove them.
----------------------------------------------------------------------------------------- This function removes the explosion
local function remove_explosion( event )
local phase = event.phase
if phase == "loop" then
local explosion = event.target
explosion:removeEventListener( "sprite", remove_explosion )
explosion:removeSelf()
end
end
-- This function makes a new explosion.
local function make_explosion( x, y )
local explosion = sprite.newSprite( explosion_set )
explosion.x = x
explosion.y = y
explosion:prepare()
explosion:play()
explosion:addEventListener( "sprite", remove_explosion )
return explosion
end
----------------------------------------------------------------------------------------
alien.transitions = transitions
table.insert( alien_array, alien )
local function create_timer_callback( alien )
local alien = alien
return function()
make_bomb( alien.x, alien.y )
end
end
local bomb_delay = math.random(1000, 2000)
alien.bomb_timer = timer.performWithDelay( bomb_delay, create_timer_call
back( alien ), -1 )
end
local alien_timer = timer.performWithDelay( 1000, make_alien, -1 )
----------------------------------------------------------------------------------------
max_speed = 4
accel = 2.5
right_limit = display.contentWidth - 20
left_limit = 20
vx = 0
= 2
= 1
= 4
= 5
ship.currentFrame = 3
end
if ship.x > right_limit then
ship.x = right_limit
vx = 0
elseif ship.x < left_limit then
ship.x = left_limit
vx = 0
end
end
Runtime:addEventListener( "accelerometer", on_accelerometer )
----------------------------------------------------------------------------------------
xMin
xMax
yMin
yMax
=
=
=
=
bounds.xMin
bounds.xMax
bounds.yMin
bounds.yMax