My spawn object with tables doesnt work!

Edit: I think i know the problem! I am also cancelling the transition so i do recall the table but i just need to recall the transition again! Im going to look up how to do that exactly!

I am trying to recall this line but it gives me an error!

enemytable[enemyCnt].trans = transition.to ( enemytable[enemyCnt], { x=centerX, y=centerY, time=math.random(2500-speedBump, 4500-speedBump), onComplete=hitPlanet } )

for i = 1, enemyCnt do if enemytable[i].trans then transition.cancel(enemytable[i].trans) enemytable[i].trans = nil end end for i = enemyCnt, 1, -1 do -- enemycnt till 1 everytime -1 display.remove(enemytable[i]) enemytable[i] = nil end enemytable = nil

Hi there!

I am trying to set the table back to what it was with the sceneshow… i dont have much there only 2 functions.

The table is set again with enemytable = {}, this should set the table back since the for loop sets it to nil. All i need to do is set it back to {} right?

-- "scene:create()" function scene:create( event ) local sceneGroup = self.view -- Initialize the scene here. -- Example: add display objects to "sceneGroup", add touch listeners, etc. 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). print("Show play scene") 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. createPlayScreen(sceneGroup) setUpDisplay(sceneGroup) enemytable = {} end end

Danny,

I imagine that one of 2 functions at the end of the show function, handle the initial spawning of the enemies, but I am just guessing. If so,  I would think you need to move the last line  ‘enemyTable = {}’ up 2 lines, to just above the call to those 2 functions (createPlayScreen) & (setUpDisplay).  You need to make sure the table {} gets assigned to enemyTable, before you call those functions.

The error you mention with regards to the transition call , is likely because of the same issue, where you assign enemyTable after the function calls, and as such the table is nil and those transition calls are using enemyTable which does not exist when that code is ran.  At least that is the best I can tell from the limited bit of code you show here.

I figured it out! I made an function that allows it to reset and now it all works!
Now all i need to do is get the graphics and music done! Thank you~
By the way… have you seen my private message? It would be great if it was possible!