Can't find a source for an event I need!

Hello all, 

I’m a bit in a bind here. I need to have a character (alien) fly from one end off the screen to another in random sequences. At random times i need the alien to drop a bomb. I’m not exactly sure how I can go about it. I have the alien down ,but I’m not sure how to spawn them off screen and have them move from right to left in one straight motion. 

I would look at the transition.to() library. Create your alien. Set him off screen by setting the .x value to some negative value such as:

local function removeAlien( target )       target.removeSelf()       target = nil end local function spawnAlien()     -- code to create the alien     alien.x = 0 - alien.width + display.screenOriginX   -- position off screen     transition.to( alien,  { time = 2000, x = display.actualContentWidth + alien.width, onComplete=removeAlien } )  -- move across screen     local dropBombTime = math.random( 1800 ) + 200 -- since we are moving the alien over 2 seconds (2000 ms), we want to wait                                                                                       -- until it's on screen before it drops the bomb     timer.performWithDelay( dropBombTime, dropBomb, 1)  -- drop the bomb end spawnAlien()

This of course will only spawn one alien, but lets get you started with it. You will need to of course provide the code to drop the bom and make the alien and tweak to your needs.

Rob

I would look at the transition.to() library. Create your alien. Set him off screen by setting the .x value to some negative value such as:

local function removeAlien( target )       target.removeSelf()       target = nil end local function spawnAlien()     -- code to create the alien     alien.x = 0 - alien.width + display.screenOriginX   -- position off screen     transition.to( alien,  { time = 2000, x = display.actualContentWidth + alien.width, onComplete=removeAlien } )  -- move across screen     local dropBombTime = math.random( 1800 ) + 200 -- since we are moving the alien over 2 seconds (2000 ms), we want to wait                                                                                       -- until it's on screen before it drops the bomb     timer.performWithDelay( dropBombTime, dropBomb, 1)  -- drop the bomb end spawnAlien()

This of course will only spawn one alien, but lets get you started with it. You will need to of course provide the code to drop the bom and make the alien and tweak to your needs.

Rob