SceneManager

Posted by Danny, Posted on August 27, 2011

4 votes

Download here : http://code.google.com/p/scene-manager/downloads/list
Please direct all feedback here : http://developer.anscamobile.com/forum/2011/08/27/release-scenemanager-v10-try-it-now-alternative-director-class

Hey guys.

I have made a library for handling scene changes which can be used as an alternative to the director class.

It features the following :

1) No memory leaks. I have tested and tested and tested. I cannot get it to leak any texture or main memory. More people who test this though the better as this is my main goal.

2) Scene change effects including : "fade", "zoomOutIn", "zoomOutInFade", "zoomInOut", "zoomInOutFade", "flip", "flipFadeOutIn", "zoomOutInRotate", "zoomOutInFadeRotate", "zoomInOutRotate", "zoomInOutFadeRotate"

3) Prevention of accidental button presses during transitions. The way the code is set up it is impossible to re-press buttons on the current scene while transitioning and not possible to touch buttons on the next scene until the transition is complete. As you know this saves all kind of headaches.

4) Error checking, there is checks in place for passed effect type and so forth.

5) Cleanup function. Pass anything you want cleaned/removed into the cleanup function and it will dispose of it for you after the first scene transition is complete.

Eg :

1
2
3
4
function localGroup:cleanUp()
        localGroup:removeSelf()
        localGroup = nil
end

6) It also has similar syntax to director to allow for a more or less seamless changeover :
With the added feature of being able to pass in the time it should take for the transition to complete

1
2
3
4
5
scene:changeScene(sceneToLoad, effect, [time]) --Time parameter is optional defaults to standard 500ms if not specified
 
eg :
 
scene:changeScene("menu", "fade", 1000)

For a full list of supported effects, please see the included sample mainMenu.lua. (You can also run the project to see all the effects in action)

Thanks!


Replies

doubleslashdesign's picture
doubleslashdesign
User offline. Last seen 15 hours 27 min ago. Offline
Joined: 27 Nov 2010

I've been playing with it a bit today and I like. Good Work!

Herman Wapenaar
User offline. Last seen 4 weeks 3 days ago. Offline
Joined: 31 Aug 2010

Hi Danny,

Started a new project using it. No issues thus far. What is your conditions for code usage?

Thanks,
Herman

canupa.com's picture
canupa.com
User offline. Last seen 21 hours 28 min ago. Offline
Joined: 20 Jun 2011

@Herman the google code page says:
"Open Source MIT License"
http://www.opensource.org/licenses/mit-license.php

-finefin

Danny's picture
Danny
User offline. Last seen 3 hours 59 sec ago. Offline
Staff
Joined: 17 Aug 2011

Yup "Open Source MIT License"

Do with it as you will :)

staytoooned's picture
staytoooned
User offline. Last seen 1 week 1 hour ago. Offline
Joined: 8 Sep 2010

I'm getting an error when I use the SceneManager to return to my main menu screen called "home". I copied your example code and changed it to my home scene and here is the error message I keep getting:

1
2
3
4
5
6
7
8
9
10
Runtime error
        ...uQBD6VAnYAf++++TI/-Tmp-/TemporaryItems/140/scene.lua:154: ERROR: table expected. If this is a function call, you might have used '.' instead of ':'
stack traceback:
        [C]: ?
        [C]: in function 'insert'
        ...uQBD6VAnYAf++++TI/-Tmp-/TemporaryItems/140/scene.lua:154: in function 'changeScene'
        ...D6VAnYAf++++TI/-Tmp-/TemporaryItems/140/newscene.lua:61: in function 'sceneChange'
        ...YAf++++TI/-Tmp-/TemporaryItems/140/musicroutines.lua:55: in function 'customFunction'
        ...QBD6VAnYAf++++TI/-Tmp-/TemporaryItems/140/helper.lua:823: in function <...QBD6VAnYAf++++TI/-Tmp-/TemporaryItems/140/helper.lua:795>
        ?: in function <?:215>

This only happens when I want to return to my main screen. Please help!

Herman Wapenaar
User offline. Last seen 4 weeks 3 days ago. Offline
Joined: 31 Aug 2010

Double check your code:

"function call, you might have used '.' instead of ':'
stack traceback:".

I suspect you might have scene.changeScene instead of scene:changeScene?

It's a common mistake I make when swopping from C#.

staytoooned's picture
staytoooned
User offline. Last seen 1 week 1 hour ago. Offline
Joined: 8 Sep 2010

I used the correct code because when I replace "home" with another scene it works. It seems to be tied to going back to the main menu scene. I can't seem to find the error. Thanks.