Overriding the update method

Topics: Actions and Control Logic, Android, Performance
Aug 19, 2014 at 6:40 PM
At the beginning of my scene i call the ScheduleUpdate method which moves a background image by subtracting a fixed value from the Y axis .

On windows Phone this works fine, by on android the game does not move

Is overriding the Update method a no no ?
Aug 19, 2014 at 7:35 PM
Edited Aug 19, 2014 at 7:36 PM
This works fine. Make sure you are using the correct signature:

public override void Update(float dt);

If on Android the sprite does not move, then what does it do? You should verify the location of the sprite such as:
 private float _timeSinceLastReport = 0f;

 public override void Update(float dt) {
   _timeSinceLastReport += dt;

  // Remember the position is a value object, not a reference object
  mySprite.Position = mySprite.Position + new CCPoint(0f, 34f); // Yucky temporary object instantiation

  if(((int)_timeSinceLastReport) % 2 == 0) {
     // every 2 seconds report on the location
     CCLog.Log("My sprite is at {0}", mySprite.Position);
Aug 20, 2014 at 2:57 AM
it is weird this problem only happens when the game is running on a connected device in debug mode. A samsung galaxy tab 2
Aug 20, 2014 at 6:08 AM
I'll try to reproduce it on our galaxy tab 2. My guess is that the update selector is not being called during the timing loop of the scheduler.
Aug 20, 2014 at 11:10 PM
I added some code last night to the scheduler to make it more robust during the update calls. If one update would fail, then all updates would be skipped. This change might fix your problem ... not sure.
Aug 21, 2014 at 6:56 AM
thanks would look at it this weekend and give feedback
Aug 25, 2014 at 4:51 AM
the fix worked . no more fps drop debugging on connected device
Aug 25, 2014 at 4:18 PM
Glad to hear that! The fix is also in the NuGet package version 1.4.1