Game Development Community

onTouchDown broken in some cases - beware! (1.6 Legacy)

by Warthog · in iTorque 2D · 04/12/2013 (3:24 pm) · 0 replies

I've spent the day struggling with a recurring crash in the running version of my game (using 1.6 Legacy).

My game starts, loads a sceneGraph, then loads a sceneGraph (using loadLevel) with the welcome screen in it. Nothing fancy, three buttons 1. starts game, 2. shows instructions, 3. shows credits. I set these buttons to use mouse events and set them up using something like this: showCreditsButton::onTouchDown(). Each function basically loaded a new sceneGraph (using loadLevel) into the current sceneWindow.

This turned out to be HIGHLY UNSTABLE and would cause a full crash about every 4th or 5th time you would click one of these buttons.

I then stopped loading new sceneGraphs (levels) for credits and instructions and instead just swapped the graphics on the sceneGraph. This made those two buttons ROCK SOLID, but I was still getting crashes when I touched the StartGame button, every 4th or 5th time. Not acceptable.

So I stopped using "use mouse events" and stopped using "::onTouchDown()" ----- now I'm binding a function to touchdown like this:

welcomeActionMap.bind(touchdevice, touchdown, "welcomeTouchesDown");

and then in the function "welcomeTouchesDown" I am using pickPoint to determine if the user has touched a button and then executing the button code. Conor gives a great example of this at:

http://www.garagegames.com/community/forums/viewthread/127943/1#comment-817046

This solution APPEARS to be ROCK SOLID.

So in conclusion DON'T use ::onTouchDown to trigger a loadLevel command.

My advice anyway, FWIW.