Storyboard API Questions

@RAoM_games: That’s great to hear! Thanks for doing that test, and I’m glad see that the results turned out good :slight_smile:

@leonZak: Thanks for bringing this to our attention. Do you have similar experience using other Android devices + Storyboard, or just that phone? We’ll be looking more into this.

@lKinx: Just from looking at it, seems like your code looks good. Once you subscribe, you’ll have access to the API and be able to play around with the sample code and easily test your code out (I also encourage changing things and messing around with the samplecode itself for familiarity). Also, in your exitScene you should remove event listeners, stop timers, etc. and remove objects in your destroyScene event.


Regarding physics bodies…

Storyboard does not automatically remove physics bodies, because there’s no way to predict 100% what everyone wants their scene to do. Therefore, nothing is unloaded unless you explicitly tell storyboard to do so, or on a low memory warning (in which case the least used scene’s ‘view’ group will be removed).

All of the adding/removal decisions are left up to you. Physics falls in the same realm as Runtime listeners and timers. If you add event listeners, timers, etc. as always, it is your responsibility to ensure they are removed at some point.

In order to provide flexibility, we have to leave what actually goes INTO the event listeners up to you.

We believe that the four events provided (createScene, enterScene, exitScene, and destroyScene) encompass just about all aspects of the scene creation/removal/transitioning process.

My suggestion for physics bodies would be, since they are removed when you call ‘removeSelf’ on an object, I would just create the objects during ‘createScene’ and then remove them during a ‘destroyScene’ event.

For the actual physics simulation, I would do as user Yogamatta suggested and start/stop physics during your enterScene/exitScene events. [import]uid: 52430 topic_id: 17828 reply_id: 70089[/import]

I’ve had the exact same problem as leonZak with every version of storyboard since it’s release. It always freezes on the transition from scene 2 to scene 3. Tested on the Droid X and build from Mac and Windows with the same result.
I keep hoping it’ll be fixed soon because I’m looking forward to using it on future apps.

Jeff
[import]uid: 14119 topic_id: 17828 reply_id: 70167[/import]

The following caused my error using quotation in a find/replace.

local previousName = storyboard.getPrevious()

local previousScene = storyboard.getScene( previousName )
–storyboard.purgeScene( “scene1” )
–storyboard.purgeScene( “previousName” ) wrong!
storyboard.purgeScene( previousName") --correct [import]uid: 6288 topic_id: 17828 reply_id: 70396[/import]

I know I saw this somewhere else, but I can’t find it:
What is the best way to create a background image that stays throughout all the scenes? I assume it is better to load it once, rather that load it on every scene change. If I put it in the main.lua file, the background is loaded above the rest of the app. What is the best way to do this? [import]uid: 38000 topic_id: 17828 reply_id: 70470[/import]

Sort of the same as Peters but with variables.

Peter, what I have done is make my scenes have a transparent background so I can watch the layer get deleted below it. If it is just 1 image you could set it up to always stay on if you skip this

function scene:destroyScene( event )  
  
 print( "((destroying scene 2's view))" )  
end  

? not to sure, you wouldn’t want anything else to be on there so maybe just a scene with that image that doesn’t destroy itself and move on to the next scene. (again someone help him out if I am wrong)

I set up a map in my function init() in main that contains my Map[], playerX, PlayerY, Player XY and I can’t access it in another scene?

How do I make data accessible across multiple scenes?
**This topic could use its own forum [import]uid: 100299 topic_id: 17828 reply_id: 70620[/import]

@leonZak and HabitatSoftware: There seems to be an issue with the ‘showNativeActivityIndicator’ argument on Android devices, so I suggest until we get this worked out that you don’t use that optional argument. In the Storyboard sample, going from scene2 to scene3 is the only place that has that parameter set to true.

e.g.
storyboard.gotoScene( true, “scene3”, “fade” )

should be:
storyboard.gotoScene( “scene3”, “fade” )

In the next update, I think we’re going to remove that argument and allow users to control the native activity indicator on their own within their listeners.
@peter9221: When you call ‘require “storyboard”’ for the first time, it creates a display group on the stage (which will hold all of your scene view groups. So to create a background image, you can do it in two ways:

  1. In your main.lua, create the background before you call ‘require “storyboard”’.

  2. Or create your background at any time and call “background:toBack()” to place it behind all other objects/groups in the display hierarchy. [import]uid: 52430 topic_id: 17828 reply_id: 70675[/import]

Tried it without the ‘showNativeActivityIndicator’ argument and it works on the Atrix.

thank you.
[import]uid: 101604 topic_id: 17828 reply_id: 70679[/import]

Quick update, the strange activity indicator issue on Android has been fixed.

We decided to deprecate the ‘showActivityIndicator’ optional first argument to storyboard.gotoScene() … Keep a look out for the daily build with the fix in it. In the meantime, just ensure you’re not using that argument and you’ll have no issues.

Also, previous code that uses that argument will be fine (nothing will break).

Thanks for those who identified the issue! [import]uid: 52430 topic_id: 17828 reply_id: 70683[/import]

Is it possible to goto the same scene by just calling storyboard.gotoScene( “lvl1” ) when your already on a lvl1 scene for example? like for a retry button for example?
I had a go but just seems to go into a infinite loop and crashes

Thanks [import]uid: 94536 topic_id: 17828 reply_id: 71311[/import]

@ncass: We made a workaround by creating a “dummyScene”. The dummyScene first removes the previous scene and then calls gotoScene(previousScene). So if your retry button calls the dummyScene, the scene will be restarted. [import]uid: 88922 topic_id: 17828 reply_id: 71400[/import]

I’m playing around with Storyboard, and anytime I use an Android or Kindle (aka non iOS dimensions) it crops off the top and bottom portion of the scene during the transition. So in effect, it puts a big black bar on top and bottom of the screen, then transitions it out.

I’ve tried this on the Storyboard sample code and can reproduce. Change the background on scene1 to take up the full screen, then run on any Android device and you’ll see it crops it right before the transition.

Are Android builds not supported on Storyboard yet? Running build 698. [import]uid: 84258 topic_id: 17828 reply_id: 71529[/import]

@kbradford: The reason why you’re getting black bars with the WidgetDemo sample is due to the fact that the config.lua is set to “letterBox” with a width of 320x480 (iPhone dimensions).

If you’re building for a specific device dimension (e.g. Kindle’s 1024x600 display), you should set your width to 600 and the height to 1024 to avoid letter-boxing (or stretching). [import]uid: 52430 topic_id: 17828 reply_id: 71597[/import]

@ncass: I’m not able to reproduce the infinite loop you’re seeing when calling the same scene. If you modify the Storyboard sample code, scene1, and change the call to storyboard.gotoScene() from “scene2” to “scene1”, you’ll see that the scene successfully transitions to the same scene (effectively reloading it, but with an optional effect).

In your exitScene listener, are you stopping timers/transitions, and removing touch event listeners?

[import]uid: 52430 topic_id: 17828 reply_id: 71622[/import]

@jonathanbeebe That would be doable if I was only building for a handle full of devices, but I build for Android/Kindle/iOS and I never know what the resolution will be for the device that’s installing. Isn’t that the purpose of using letterBox and dynamic scaling, to handle a variety of resolutions?

If we have to specify the exact resolution to use Storyboard, that makes it pretty much useless to me. [import]uid: 84258 topic_id: 17828 reply_id: 71921[/import]

@kbradford: So you’re saying your app does not have the borders at the top/bottom, but when you do a scene transition it does?
[import]uid: 52430 topic_id: 17828 reply_id: 71925[/import]

Yep, exactly. I’d be happy to provide screenshots, but follow the directions in my previous post and you can reproduce in the sample storyboard code. Directions:

Change the background on scene1 to take up the full screen (eg change bg.jpg to be 600x400), then run on any Android device in the simulator and you’ll see it crops it right before the transition. Running on PC simulator. [import]uid: 84258 topic_id: 17828 reply_id: 71936[/import]

Hi Jonathan,

One quick update about my game that uses Storyboard. I put forward that I’m not the best in managing memory myself.

When my game is played in a sequence for 3-4-5 times, from the beginning to the end (22 scenes), it uses a pretty stable memusage value that is slightly less than 1 MB. This is the bundle I’ve submitted to the AppStore, which I compiled using Corona 689.

I’ve now downloaded Corona 703 and can see that the same game, the same bundle, uses 1.5 times the value said before.

Does this value sums up to the textMemusage when computing the grandtotal for a “memory warning” not being thrown out by the older 3G devices (which is 3 MB)? Most of all, is it more convenient to me going back to 689?

Thanks in advance.
[import]uid: 67641 topic_id: 17828 reply_id: 72164[/import]

I found something. Let me describe. I am building a scene with some elements outside the screen. If I add those elements to the scene display group in createScene and at the same time use effects like “fromLeft”, the scene gets all wrong. It’s kinda centers in between so the elements I place outside is visible. But if I add those elements to the group in enterScene everything is all right. I don’t know if it’s a bug or just something we need to be aware of. [import]uid: 40334 topic_id: 17828 reply_id: 72520[/import]

Hi i was wondering if there was a way to make a changeScene event in a button, so when you click a button/text object, it takes you to a new scene.

Thanks. [import]uid: 69054 topic_id: 17828 reply_id: 72552[/import]

@mobilefun4me: In response to the “can’t allocate region” error:

I also received an error like that before, when going BACK to a scene that previously loaded fine, but I was able to identify the issue (it was my fault).

What happened was that I assigned a touch listener to go to the next scene, but I had forgot to remove the touch event listener, so when the next scene was up, it was still receiving touches and a double-call to storyboard.gotoScene() was trampling all over itself causing the same error that you specified above.

Please verify that your touch listeners, runtime listeners, timers, transitions are removed and cancelled during your “exitScene” event and see if you’re still having the same issue. [import]uid: 52430 topic_id: 17828 reply_id: 72750[/import]