Portal flash version on codea

I tried to make portal 2d on codea and made quite a few things and then thought lets make a level(cause the first few wont have much complications in them). I made the first level and then the second one and tried shifting between them using FSM. But unfortunately if I switch rapidly codea crashes sometimes it doesn’t and sometimes if I just switch it crashes. Here’s the code I wrote https://gist.github.com/Saurabh96jun/5567707. If anyone finds a solution please help me out.

I tried your program and it totally locked up my iPad1. I couldn’t get out of the program except to power down and restart the iPad. Not sure whats happening yet, but it could take awhile if I have to power down the iPad each time.

I don’t know why that’s happening. Could it be because too many things are happening at once.

Hi @Saurabh. Not sure the exact problem, but can I suggest creating a level class - this will save in repeating a lot of code as you add levels. For example:

class Level()

Level:init(pass your setup variables here - probably just some sort of walls table, your player start position and exit position)
End

Level:draw()
Call your wall drawing function here
End

Then from your main setup you could create a level table

Leveltable={Level(l1_walls,player position,exit position),Level(l2_walls,player position,exit position)}

And set up a variable called currentLevel=1

In your main draw then call

Leveltable[currentLevel]:draw()

Hope this makes sense?

Closed. Couldn’t find a solution.