accelerometer function ignored using Director

Hi

Yet more on this…

So, I have the game (working in a single file) now as one of the screens using the Director class. It’s early days, so I have a settings screen, menu, the game screen, level screen and a second screen.

The app currently opens fine and allows me to navigate : main > menu > game > either of the other 2 screens. I can navigate around the screens fine and the game loads perfect first time, but when I navigate back to it from another screen the accelerator function is ignored.

I’ve done a few tests and on screen feedback shows me that the other functions are executing, just not the “onTilt” function.

Can anyone explain why this might be - does the Director class clean in such a way that accelerator functions might be ignored after first load - or should I be adding something.

I’ve tried adding additional event listeners inside functions that are know to be executing, but this also has no effect.
Thanks in advance.

Hi

More to the below. I’ve commented lines out again and :

  • enterframe and accelerometer functions work fine (I’d read that these are global and may be ignored)
  • the functions etc are fine when empty, but lines with a force or linear impulse breaks it
  • the shadow works fine, but “shadow.y = shadow.y + 15” still breaks it - as do the parallax statements. I’m not sure why this would make any difference either, but looking into it…

All the above work fine in the single file version, just not correctly when navigating in Director.
Some of these work fine in the Simulator, but not on my 3G - perhaps it’s a safe delay issue?

Any ideas would be very welcome…

cheers


Hi

I’m fairly new to using Director.

I’ve have a single file project that works fine, but have a few problems when it’s moved inside the Director class:

If I comment certain lines out it works fine, however it throws up strange errors where :

  • a shadow placed ‘shadow.y = myAnim.y’ works fine, but placing the shadow 15px down ‘shadow.y = myAnim.y + 15’ doesn’t work. It allows the screen to be changed (to screen2 for example), but when I change back (screen1) I can hear the sounds load in for screen2 and screen1 stays on screen.

  • if I uncomment a line that has an ‘myAnim:applyForce’ command in it, again I can navigate away, but coming back doesn’t unload the existing screen.

  • if I uncomment a parallax statement ( for example : background.x = 240 - myAnim.x/4 ), the same thing happens.

So, it’s really just a few lines that seem to cause the error : those with applyForce or calculations attached. All of these also have a reference to myAnim - the movieclip I’m using, but referencing it elsewhere is also fine.

Everything has been made local. Again, the screens swap one way, but not back though the sounds appear, so the file must load. Can anyone let me know if this is something I’ve missed, perhaps to do with movieclips, or something other?

Thanks.
[import]uid: 10814 topic_id: 10130 reply_id: 310130[/import]

I had the same problem of the accelerometer only working on the first level of a game, to fix it I had to add

Runtime:removeEventListener("accelerometer", onTilt )  

Before the director:changeScene in a function.

Hope that helps. [import]uid: 26801 topic_id: 10130 reply_id: 40802[/import]

Hi George

Thanks for this. I did come across this by chance a couple of weeks ago - after quite some time trying various lines commented out. Like you I found that all Runtime listeners must be cleaned before leaving any screen for this to work, so I’ve included mine in the clean function.

Thanks again for your response… [import]uid: 10814 topic_id: 10130 reply_id: 40811[/import]