Simple scene selecter/state machine

I got tired of re writting code to create a state machine. This allows you to create Scenes or states in your project. Just add the Scene tab into your project. Create a class or table for each scene. To add a scene use:

--To change to a new scene use: 
Scene.change("name")

function setup()
--set a scene 
Scene("name",classname)
--if you'd like a parameter to switch scenes
Scene.parameter()
end

function draw()
Scene:draw()
end

function touched(t)
Scene:touched(t)
end

The other tabs are for the demo only.

Updated to allow persistent scenes.

Code

Briarfox . Is good , very good . is that I had tired of working with change GameStates , now is more interactive whit my others classes :slight_smile:

Glad you like it, it’s simple and nothing special but it sure beats re inventing the wheel with every project I work on!

I’m thinking about adding in the ability to add layers. So you could layer a scene for UI’s and such.

Yea is true , is better , and I agree

@Luismi Do you use an iPad1. If so, how do you go about loading @Briarfox example code that’s in the link above. I see his program with 8 tabs, but I can’t figure out a way to copy it on my iPad1 unless I copy/paste each tab individually. I was just wondering, can you copy it all at once or do you have to copy/paste each tab also.

If I have an ipad 1, download the draft @Briarfox from CC
Sometimes the ipad tends to close the application of codea when I download a code but sometimes not @dave1707

@dave1707.I do not DOWNLOAD from the link you put in the post, I DOWNLOAD from the ipad in the community

@Luismi If I try to do anything on CC other than look at stuff, CC crashes. I got the latest update, but still no luck. I guess if I want to run any examples that people post, I have to load it tab by tab. If there’s too many tabs, I just don’t bother.

I know that happened to me, but not all the time @dave1707.

I never taste a project without first download of the Community, otherwise SHUT CC always tends to the ipad 1 :frowning:

I always post a pastebin with all code in 1 tab, for as long as CC doesn’t work for everyone, once it does, I’ll post all code there (projects, questions will be posted on here since that’s not a full code :wink: )

@Dave1707 can you get in touch with Toffer, we are really trying to get this working on ipad 1.

@Briarfox I sent him a message.

@Luismi @Briarfox One thing I didn’t know. When I try the link above in the first post, I see the program with 8 tabs but I didn’t see anyway to copy the program. Not until I was working with @Toffer, who told me to rotate the iPad from portrait mode to landscape mode. I always work in portrait mode. I then saw the copy icons and was able to copy and paste the whole program at once. But working with Toffer, the iPad 1 is still crashing with CC, but I think we may have found something.

@dave1717. you’re trying to download the code using the link above?

because from the link I feel the same as you? @dave1707

@Luismi Yes, and it works. Tap on this link

http://codea.housercompany.com/alpha/index.php?v=837

then touch and hold the copy icon for a second or so. The select copy. Go to Codea and press and hold the plus sign ( add new project). It will ask for a name, and save all the tabs. Well it used to work. I tried it again and it wouldn’t copy.

EDIT: I just tried it again and it did the copy.

EDIT: If I tap and hold the icon, it doesn’t work. I have to tap and hold just to the right of the icon for it to work.

yea it works. @dave1707

@Luismi I don’t think there’s many of us iPad 1 users left.

if true , but we can do? :-S

@dave1707 i still have a ipad 1