This is a continuation of the discussion from the API pages. http://developer.anscamobile.com/content/storyboard [import]uid: 7559 topic_id: 24283 reply_id: 324283[/import]
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. [import]uid: 101897 topic_id: 24283 reply_id: 98513[/import]
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! [import]uid: 54776 topic_id: 24283 reply_id: 99385[/import]
– Called BEFORE scene has moved onscreen:
function scene:willEnterScene( event )
and again its Called AFTER! [import]uid: 130910 topic_id: 24283 reply_id: 100283[/import]
Looks like the new Scene template incorrectly has the function
[lua]function scene:willExitScene[/lua]
instead of
[lua]function scene:didExitScene[/lua] [import]uid: 44647 topic_id: 24283 reply_id: 100393[/import]
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) [import]uid: 26049 topic_id: 24283 reply_id: 100422[/import]
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 [import]uid: 86417 topic_id: 24283 reply_id: 100429[/import]
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 [import]uid: 5942 topic_id: 24283 reply_id: 101251[/import]
Hi!
I don’t understand why do you call the group inside every function in the template:
[code]-- 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[/code]
…
Is it better call the group before the functions or is it worst?
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
… [import]uid: 141611 topic_id: 24283 reply_id: 102253[/import]
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. [import]uid: 105206 topic_id: 24283 reply_id: 102495[/import]
Problem solved
thanks [import]uid: 105206 topic_id: 24283 reply_id: 102498[/import]
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.
[import]uid: 41884 topic_id: 24283 reply_id: 103108[/import]
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. [import]uid: 52430 topic_id: 24283 reply_id: 103423[/import]
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. [import]uid: 5942 topic_id: 24283 reply_id: 103459[/import]
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.
application.content =
{
width = 320,
height = 427,
scale = "letterBox",
imageSuffix =
{
["x1.6"] = 1.5,
["x2.4"] = 2,
}
}
Thanks for your help.
[import]uid: 74786 topic_id: 24283 reply_id: 104277[/import]
[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 [import]uid: 67217 topic_id: 24283 reply_id: 104304[/import]
@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. [import]uid: 84637 topic_id: 24283 reply_id: 104464[/import]
[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 [import]uid: 67217 topic_id: 24283 reply_id: 104345[/import]
@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:
[lua]function scene:enterScene( event )
myButton:addEventListener( “touch”, myButton)
end[/lua]
That’s all it needed. Nothing else. Cheers. [import]uid: 67217 topic_id: 24283 reply_id: 104469[/import]
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
[lua]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[/lua] [import]uid: 124739 topic_id: 24283 reply_id: 107729[/import]