My first question is, how would I go about spawning enemies in a game like Doodle Jump, where my character is moving upwards and would have to avoid these enemies.
My second question is, how would I go about taking my background image and replicate itself on top of the original, and so on, so I would have an infinite scrolling background, rather than placing each one manually. Is there a better way to create an infinite scrolling background?
All help is appreciated! [import]uid: 7116 topic_id: 6471 reply_id: 306471[/import]
end
timer.performWithDelay( 0, randomStuff, 1 )[/lua]
That is not all you will need for a good effect but, should help you for a start. For your second question if your background is static then you can just say bg.y = character.y however if your bg is meant to change as your character progresses what I did is made the image in photoshop and then cut it into smaller pieces and created some functions like these, [lua]local function controlBG1()
if ship.y > -240 then
local bg1 = display.newImageRect(“bg1.png”,960,500)
game:insert(bg1)
bg1.x = 0; bg1.y = 240
bg1:toBack()
elseif ship.y < -240 then
game:remove(bg1)
end
end
local function controlBG2()
if ship.y < 338 then
local bg2 = display.newImageRect(“bg2.png”,960,500)
game:insert(bg2)
bg2.x = 0; bg2.y = -260
bg2:toBack()
Keep in mind the texture memory on mobile devices is quite limited so youre going to have to optimize your background so it’s not to large otherwise it will cause your game to lag. Hope I helped [import]uid: 11465 topic_id: 6471 reply_id: 22606[/import]
timer.performWithDelay( 7000, randomStuff, 0 )
timer.performWithDelay( 0, randomStuff, 1 )[/lua] I don’t know if that applies to you but now it will rerun that function every seconds replacing the objects at a point ahead of your character. [import]uid: 11465 topic_id: 6471 reply_id: 22764[/import]