Game Development Community

onUpdateScene doesn't appear to be working

by Tony Pieper · in iTorque 2D · 06/22/2009 (3:11 am) · 3 replies

I'm trying to adapt the Whack-A-Mole tutorial that comes with the TGB documentation so that it runs on the iPhone, but there seems to be a problem with the timer (I'm thinking onUpdateScene isn't being called, but I'm not sure). I've got everything set up so that it compiles and runs in both the Simulator and on the iPhone, but the timer won't update, the "Game Over" text never appears, and the moles just keep coming (although everything works like it should when played through iTGB).

I'm running XCode Version 3.1.3 (the latest SDK), and my iPhone was running the latest 3.0 Beta (GM Seed, I think). I'm compiling the project for 2.2.1, but I've tried 2.0 and 3.0 as well with the same results (using Debug or Release, and iTGB_Optimize).

I'm not really sure where to go from here. I tried adding a timer to MoleLevel, and replacing onUpdateScene with onTimer, but that only stopped the timer from functioning in iTGB.

Thanks for the help.

Screenshots for those who are interested

While running under iTGB
pieper.on-rev.com/images/Mole1_iTGB.png
While running under iPhone Simulator
pieper.on-rev.com/images/Mole2_iSim.png

The timer is set to 10 seconds, but as you can see from the second image, it takes longer than 10 seconds to miss 72 moles

About the author

Recent Threads


#1
06/22/2009 (5:14 am)
If you compile with PUAP_OPTIMIZE you need to add this to your game.cs to enable the update callbacks:

SceneGraph.UseUpdateCallback = true;

That's assuming you have named your scene graph "scenegraph" in the editor. Otherwise use whatever method your familiar with to set the variable.
#2
06/23/2009 (3:38 am)
Thanks for the info, but I couldn't get the UseUpdateCallback to work (even tried enableUpdateCallback).

Fortunately, I tried going back and re-compiling using just straight iTGB as the target, and everything compiled and works! I can't remember why I was using iTGB_Optimize, but I think it had something to do with a previous attempt always failing to compile.

Anyhow, things are working now. Thanks for the help!
#3
06/23/2009 (7:42 am)
The reason is iTGB_Optimize enables the PUAP_OPTIMIZE flag which disables the updatecallbacks.

To use updatecallbacks in optimize mode you have to set the flag I told you about.

To get the code I gave you to work you have to name the scenegraph object to "scenegraph" so that you can reference it from script to set that flag.

It works perfectly for me once I do that.