Storyboard

37 replies [Last post]
Tom
User offline. Last seen 4 years 6 weeks ago. Offline
Joined: 13 Jul 2010

This is a continuation of the discussion from the API pages. http://developer.anscamobile.com/content/storyboard

Replies

mwlake08
User offline. Last seen 4 years 4 weeks ago. Offline
Joined: 3 Nov 2011

Storyboard Conversion headaches

Having used Scenemanager and Director, which are very easy to implement. I am now tring to convert my App over to Storyboard. Why? For the reason I have memory Leaks with both Scenemanager and Director. Hopefully StoryBoard will close those leaks. Most likely the leaks are caused from the now deprecated use of "module(..., seeall)".

Why doesn't Ansca tailor Storyboard to use the simple implementation techniques of Scenemanager and Director to make a better "attached to the stardard API StoryBoard". So far the conversion from SceneManager and Director to SB has been far from easy.

Richard P.
User offline. Last seen 4 years 21 weeks ago. Offline
Joined: 22 Apr 2011

I love storyboard and the way it works. I've tried director and didn't like it so I found storyboard and stuck with it ever since!

latnok
User offline. Last seen 8 years 5 weeks ago. Offline
Joined: 29 Feb 2012

-- Called BEFORE scene has moved onscreen:
function scene:willEnterScene( event )

and again its Called AFTER! :(

toby2
User offline. Last seen 2 years 15 weeks ago. Offline
Joined: 11 Mar 2011

Looks like the new Scene template incorrectly has the function

1
function scene:willExitScene

instead of

1
function scene:didExitScene

Hotaman
User offline. Last seen 43 weeks 1 day ago. Offline
Joined: 23 Jan 2011

I just finished converting our latest app from director and our heavily modified original coronaui to storyboard/widget libs.

Conversion was easy BUT...

Our app has gone from being rock solid to a flaky mess.

We are using build 777 right now as it appears to be the most stable. Memory issues are now worse! when running we are using ~60MB of texture instead of the previous ~38MB loading the EXACT SAME assets! Strange to say the least. All of the assets are not being freed either even though using Cider I have confirmed that there are no references to the assets at all.

We are getting errors in the createScene event calling factory functions like display.newText().
Like a HARD CODED 160 for the x value blowing up because the system says it's a STRING!
Or a hard coded "-" for the text string blowing up because the system says it's a NIL!

We also get bus memory errors like illegal access of location $07 and table access errors saying the var is not pointing to a table when in fact is was just pointed to one and accessed in the previous instruction.

These errors happen randomly, the code may work fine through dozens if iterations then boom it blows up or it might blow up on the first pass. I have not been able to produce a repeatable error so I have not created a bug report. With 35 years of experience programming and being a certified software tester I know if I can't repeat it, they can't fix it.

At this point we have gone back to the original code, waiting for a stable system to build on. I have tried 775 thru 782 and it appears 777 is the most stable. We are not using any transitions except fade in a couple places, using fade on all transitions is much more unstable. I haven't tried any of the other transitions due to problem reports with them and objects off screen. We do have one group in one scene that is larger than the screen so I stayed away from transitions when it is involved.

Is anyone else seeing these kind of problems?

I'll post this in the daily build section as well (sorry Peach, inquiring minds NEED to know what is going on)

martin.edmaier
User offline. Last seen 3 years 48 weeks ago. Offline
Joined: 25 Aug 2011

Same story... this nil errors are weird : one small solution is somethings for example: if xSpeed~=nil then..

end...

That should solve some problems but most bugged is the Remove Scene function.

Cheers,

Martin

jbverschoor_bloomsix
User offline. Last seen 6 years 25 weeks ago. Offline
Joined: 7 Apr 2010

I get this weird error when trying to return to the menu scene:

Runtime error
bad argument #-2 to 'insert' (Proxy expected, got nil)
stack traceback:
[C]: ?
[C]: in function 'insert'
?: in function 'gotoScene'
/Users/XXXXXXXXX.lua:32: in function '_listener'
?: in function <?:514>
?: in function <?:215>

Latest daily build. I've been looking for 2 days now :S

juan-imaxina
User offline. Last seen 7 years 25 weeks ago. Offline
Joined: 12 Apr 2012

Hi!

I don't understand why do you call the group inside every function in the template:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- Called when the scene's view does not exist:
function scene:createScene( event )
        local group = self.view       
end
 
-- Called BEFORE scene has moved onscreen:
function scene:willEnterScene( event )
        local group = self.view
end
 
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
        local group = self.view
end

...

Is it better call the group before the functions or is it worst?

1
2
3
4
5
6
7
8
9
10
11
 local group 
 
-- Called when the scene's view does not exist:
function scene:createScene( event )
           group = self.view
end
 
-- Called BEFORE scene has moved onscreen:
function scene:willEnterScene( event )
       
end

...

nml
User offline. Last seen 7 years 11 weeks ago. Offline
Joined: 18 Nov 2011

Hello I have a problem. I have five sprite sheets in the main.lua. The first time that I used them is ok, but when I change to other scene I have this problem.

attempt to call method 'addEventListener' (a nil value)

Is there any way that don't remove this sprites when I change the scene?

thanks.

nml
User offline. Last seen 7 years 11 weeks ago. Offline
Joined: 18 Nov 2011

Problem solved

thanks

richard9
User offline. Last seen 2 years 5 weeks ago. Offline
Joined: 28 Feb 2011

juan: It's the same group in each instance, so you shouldn't need to pre-declare unless you need to address the group outside of each function.

Keeping the group reference inside each function helps to isolate it from your code but I'm guessing it's not critical.

jonathanbeebe
User offline. Last seen 8 years 4 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

Hello all...

Just wanted to give you a quick update. During this bug fix cycle, most of the storyboard bugs have been fixed (all that were on file, in fact). We're still waiting on build 2012.797 to post, but that one will also include some fixes, and most notably, the "scene popup" functionality that's been much requested (called overlays).

As a result of all the recent changes, several new documentation pages have been put up:

storyboard.showOverlay()
storyboard.hideOverlay()
storyboard.disableAutoPurge
storyboard.stage

ALSO: I updated the storyboard scene template to fix the typo as well as add in the new "overlayBegan" and "overlayEnded" events.

jbverschoor_bloomsix
User offline. Last seen 6 years 25 weeks ago. Offline
Joined: 7 Apr 2010

I would love to see autopurge to always autopurge, similar to director.
I know it is les performant, but it's easier to do memoryand performance profiling etc.

neufdoigts
User offline. Last seen 6 years 3 weeks ago. Offline
Joined: 8 Jul 2011

Implementing the newest build of storyboard

I've been using an old version of the storyboard API 2012.767 and would like to upgrade to the latest build to take advantage of the all the improvements (speed etc). However, my app uses the slideLeft and slideRight transitions extensively and these transitions do not seem to be handled in the same way in the recent builds (2012.799).

Take the slideLeft as an example. In the recent build, the new scene does not start animating from the far right side of the screen as one would hope for a slide left transition. It just suddenly appears abruptly about 150pixels (about 20% of screen width) in from the right. Once started the transition works fine, but with the "jump", it's unacceptable.

Does anyone have any pointers for how to avoid this problem? Are there any parameters I can send to the storyboard.gotoScene call which could help me here? My config is somewhat atypical so I'm including that here.

1
2
3
4
5
6
7
8
9
10
11
application.content =
                {
                        width = 320,
                        height = 427,
                scale = "letterBox",
                imageSuffix =
                                {
                                        ["x1.6"] = 1.5,
                                        ["x2.4"] = 2,
                                }
                }               

Thanks for your help.

Naomi
User offline. Last seen 9 weeks 3 days ago. Offline
Joined: 6 Jun 2011

[Edit] I think I got it wrong about purgeScene. From what I now understand, it doesn't nil the display objects variable, but it does unload the image (and releases the texture memory usage).

I'm still not entirely sure what removeScene does, though. Does it nil out all local variables and release them from memory? Is it what it does?

--------------------
I just read through following blog posts, and I'd like to confirm if I understood purgeScene and removeScene functionality properly:

http://blog.anscamobile.com/2011/11/introducing-the-storyboard-api/
http://blog.anscamobile.com/2012/03/storyboard-scene-events-explained/

[Edit] I just went over the "director to storyboard" blog: http://blog.anscamobile.com/2012/04/director-to-storyboard-transition-guide/

And I think I understand this better now:

purgeScene
I think what purgeScene does is to remove and nil out display objects from the scene (and I don't have to individually remove each display object using destroyScene or exitScene.)

removeScene
I think what removeScene does is to remove everything associated with the scene completely from the memory. That is, it releases the entire scene module from memory as if the scene was never accessed. However, we still need to make sure we stop timers, transitions, remove Runtime listeners, etc. when exiting the scene to be removed.

Did I get this right this time? Once I understand how I am to manage memory when using Storyboard, transitioning from director class to storyboard wouldn't be all that nerve wrecking...

Naomi

Naomi
User offline. Last seen 9 weeks 3 days ago. Offline
Joined: 6 Jun 2011

[Fixed] See my post #18 below. Cheers.

-----------------------------------------------
I set up a skeleton project with storyboard:

main.lua
menu.lua with a button (tapping on it will change the scene to scene1.lua)
scene1.lua with a button (tapping on it will change the scene to scene2.lua)
scene2.lua with a button (tapping on it will change the scene to scene3.lua)
scene3.lua with a button (tapping on it will change the scene to menu.lua)

Changing scene is working nicely without any errors, but I'm not sure if transition effects are working as expected. I used:

fromRight (over original scene)
fromLeft (over original scene)
fromTop (over original scene)
fromBottom (over original scene)

However, it doesn't look like it transitions over original scene. Instead, it shows the next scene sliding over a black screen (instead of sliding over the scene I'm leaving).

I thought, maybe, the purgeScene function inside the enterScene function in the next scene was interfering -- so I moved purgeScene function to didExitScene function (of the scene I was leaving), but it made no difference.

Is this an expected behavior (i.e., sliding over a black screen), or am I missing something.

I checked the storyboard sample code, but it includes slideLeft, fade, crossFade and slideUp, so I could not verify this.

I'd so appreciate some feedback as to what I should expect with "over original scene" effects listed above.

Naomi

Danny
User offline. Last seen 4 years 5 weeks ago. Offline
Joined: 17 Aug 2011

@Naomi: That isn't the expected behavior, if you want to submit a stripped down sample of the issue (and i mean literraly bare bones, as simple as you can make it) to bugs.anscamobile.com and reference my name, id gladly take a look at the issue.

Naomi
User offline. Last seen 9 weeks 3 days ago. Offline
Joined: 6 Jun 2011

@Danny, thank you for offering to take a look. I'll file the skeleton (absolutely a skeleton, I assure you) and will post back with the bug number.

Thanks again.

Naomi

Edit: As I was reverting back to include ui.lua, it appears that the problem is gone. I don't understand what changes made the difference, but somehow, along the way, whatever I did fixed it. I don't know what was the issue and why it's solved, but it is. I wish I know what it was that caused the problem.

Anyhow, Danny, thank you for your offer to help. It prompted me to re-examine and sort this out.

Edit2: I figured out what I did that fixed it for me. It was adding event listner to the button inside scene:enterScene event. Like so:

1
2
3
function scene:enterScene( event )
        myButton:addEventListener( "touch", myButton)
end

That's all it needed. Nothing else. Cheers.

aferryc
User offline. Last seen 8 years 22 weeks ago. Offline
Joined: 6 Feb 2012

Firstly , i'm sorry for my bad English
I get black screens when i try to go to scene "level1"
I did all display function in scene:createScene
and all listeners in function scene:enterScene
and add my custom function for my game outside of theme
I see no error in console, but i just got black screen

I think i got wrong in my createScene

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function scene:createScene( event )
        local group = self.view
        collision1 = {categoryBits = 2, maskBits = 3}
        collision2 = {categoryBits = 4, maskBits = 5}
        ground = {}
        for i = -5, 10, 1 do
                ground[i] = display.newImage("ground.png")
                ground[i].x, ground[i].y = 63*i, 450
                physics.addBody(ground[i], "static", {friction=0.5, bounce=0.8})
                ground[i].collision = onGround
                ground[i]:addEventListener("collision", ground[i])
                group:insert( ground[i] )
        end
 
        cat = {}
        cat[1] = display.newImage("tankcat.png")
        cat[1].x, cat[1].y = -128, 370
        physics.addBody(cat[1], "static", {friction=0.5, bounce=0.6, filter=collision1})
        cat[1].collision = onCat
        cat[1]:addEventListener("collision", cat[1])
        cat[2] = display.newImage("meriamcat.png")
        cat[2].x, cat[2].y = -80, 350
        physics.addBody(cat[2], "static", {friction=0.5, bounce=0.6, filter=collision1})
        cat[2].collision = onCat
        cat[2]:addEventListener("collision", cat[2])
        local dog = {}
        dog[1] = display.newImage("tankdog.png")
        dog[1].x, dog[1].y = 450, 370
        physics.addBody(dog[1], "static", {friction=0.5, bounce=0.6, filter=collision2})
        dog[1].collision = onDog
        dog[1]:addEventListener("collision", dog[1])
        dog[2] = display.newImage("meriamdog.png")
        dog[2].x, dog[2].y = 380, 350
        physics.addBody(dog[2], "static", {friction=0.5, bounce=0.6, filter=collision2})
        dog[2].collision = onDog
        dog[2]:addEventListener("collision", dog[2])
        group:insert( cat[1] )
        group:insert( dog[1] )
        group:insert( cat[2] )
        group:insert( dog[2] )
        catDog = 0
end

Richard P.
User offline. Last seen 4 years 21 weeks ago. Offline
Joined: 22 Apr 2011

No longer needed.. Delete me! :-P

michael714
User offline. Last seen 2 years 28 weeks ago. Offline
Joined: 13 Nov 2011

Hey Folks, I'm having some problems with passing parameters using gotoScene. I have a scene that I use as a menu and then a scene that I use as a game- it's a math game. The game scene is capable of offering several exercises including multiply, add, subtract or divide. The desired exercise is dictated by which button the user presses from the menu. If "Multiplication" is pressed, then operation = "Multiplication" is passed as a parameter to the game scene.

It works fine the first time you choose a particular operation from the menu scene. However, if I go back to the menu (from the game scene) and then click to try a different operation, when I get back to the game scene, the previous operation is still in effect.

It seems like I cannot override the initial parameter when I go to the game scene a second time. If anyone has any suggestions, I would really appreciate reading them.

michael714
User offline. Last seen 2 years 28 weeks ago. Offline
Joined: 13 Nov 2011

Answered my own question. I was using:

1
storyboard.purgeScene( "scene1" )

to try to purge the game scene (scene1), but I put it in createScene of my menu page. So, I moved this line to enterScene and everything is working perfectly now. Yay!

Tons of Toons Apps
User offline. Last seen 7 years 37 weeks ago. Offline
Joined: 15 Jul 2011

Hi,

I have a question related with storyboard and memory management:
-When application exits "applicationExit", do I have to purge/remove the secenes in order to free the memory? Or does the system release the memory itself we needed?

-And if the application is suspended "applicationSuspend". Should I expect the system to kill the process if the memory is needed?

Thanks!

Tom
User offline. Last seen 4 years 6 weeks ago. Offline
Joined: 13 Jul 2010

@angelpou, applicationExit will purge/remove all memory usage for your app. You need to save any program state that you would need to restore when you application restarts.

You should always assume that the OS will kill your program to get back memory after an applicationSuspend event. Most of the time you will get a applicationResume event, but there may be times when it's killed instead.

chevol
User offline. Last seen 47 weeks 3 days ago. Offline
Joined: 10 May 2011

Is there a way to insert storyboard's view into another display group? For instance I have a navigation similar to the FaceBook app (left side scrolling nav and right side view overlays the nav), and I want the right side view to contain storyboard so I can load other views into it. I have the slide and dragging of the right view in place and am loading a couple views statically and everything works fine but I would love to use storyboard to control the right side displaygroups views/scenes. Is this at all possible or am I trying to do something impossible?

juan-imaxina
User offline. Last seen 7 years 25 weeks ago. Offline
Joined: 12 Apr 2012

If you put a menu (or something else) out of the storyboard scenes (in the main for example) and above these, this will always be visible while the storyboard scenes are changing.

sjerrett
User offline. Last seen 2 years 34 weeks ago. Offline
Joined: 29 Aug 2011

jbverschoor_bloomsix, I'm having the same issue -- did you ever resolve it?

    I get this weird error when trying to return to the menu scene:

    Runtime error
    bad argument #-2 to 'insert' (Proxy expected, got nil)
    stack traceback:
    [C]: ?
    [C]: in function 'insert'
    ?: in function 'gotoScene'
    /Users/XXXXXXXXX.lua:32: in function '_listener'
    ?: in function <?:514>
    ?: in function <?:215>

    Latest daily build. I've been looking for 2 days now :S

jbverschoor_bloomsix
User offline. Last seen 6 years 25 weeks ago. Offline
Joined: 7 Apr 2010

Yeah emm.. I have to think real hard, but I think it was something stupid like filenaming, or something

Maybe it was even something like using a solon instead of a dot

Corona Rob
User offline. Last seen 24 weeks 5 days ago. Offline
Staff
Joined: 26 Nov 2012

@sjerrett are you inserting anything into "group" during the createScene() event?

itsblargmob
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 26 Jun 2012

Is there a way to properly goto a scene from an overlay scene?

For example:

menu.lua -> game.lua -> pausemenu.lua (this is an overlay on top of game.lua)

When I try to go back to menu.lua from pausemenu.lua using gotoScene(), the overlay instantly disappears...then the transition begins and menu.lua is loaded. How can I stop the overlay from disappearing when I call gotoScene()?

Corona Rob
User offline. Last seen 24 weeks 5 days ago. Offline
Staff
Joined: 26 Nov 2012

I don't think you can. Overlay's sit on top of other scenes. To go to another scene implies that the overlay needs to disappear.

itsblargmob
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 26 Jun 2012

Ah, okay. I have settled with simply fading the overlay before calling gotoScene().

I suppose one could "fake it" however, by fading in a black rectangle over the whole scene (including the overlay) then calling gotoScene() from there.

In any case, thanks for the help!

itsblargmob
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 26 Jun 2012

Actually, I've got another question.

Is there a way to entirely "nuke" a scene? In switching between scenes, I would like to completely nuke and unload the previous scene (all objects, listeners, timers, etc.) without having to manually do so in the scene's "exitScene" event.

I have tried removeScene() with no luck (listeners are still active)

Corona Rob
User offline. Last seen 24 weeks 5 days ago. Offline
Staff
Joined: 26 Nov 2012

I've found it best to not use overlay when I have to go to other places. Overlays are great if you're returning to your scene.

itsblargmob
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 26 Jun 2012

I just mean from "normal" scene-to-scene exchanges. Just looking for a way to "nuke" the previous scene so I don't have to manually remove all of the listeners/timers and things from the exitScene listener.

Corona Rob
User offline. Last seen 24 weeks 5 days ago. Offline
Staff
Joined: 26 Nov 2012

removeScene() dumps the whole scene (removes any display objects that it's managing and calls the destroyScene() event handler.

You are still responsible for stopping timers, audio that's playing that may have a call back, transitions that have onComplete handlers, etc. You probably should be making a habit of doing that in your exitScene() handler because if one of those call backs fires while your in another scene there is a good chance that you will crash with a segment violation crash.

itsblargmob
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 26 Jun 2012

Okay, sweet. Thanks again for the help!

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.