Game Development Community

Strange And Frustrating Button Behavior

by Jack-S- · in iTorque 2D · 11/29/2011 (4:18 pm) · 3 replies

Hi guys, another day and another quirky problem..

Basically I have a scene with some buttons. Now the buttons consist of just static sprites. They are spread evenly across the screen. Now the strange thing that happens is that the buttons that are not located near the center of the screen space will just simply NOT work.. If I click on the button they dont change level. infact iTorque doesnt even know it exists ( console says it cant find it.. yet it exists in datablocks!!) . I have checked the level datablocks and all buttons are accounted for.
Now for the wierd part. IF! I move this button to near the center of the screen then Magically the button starts responding!?!?!?!?!?! and hey presto the level changes!! however if I move this button back to its original place then it stops working again!!!!

I am sorry for being sarcastic in this post but my patience is now wearing drastically thin. The amount of strange quirky problems I am running into is down right ridiculous and I find myself spending MORE TIME FINDING WAYS TO SOLVE QUIRKY PROBLEMS rather than actually coding my game. Garage games take hint.

I have coded the buttons like this,

function sectorOneLevelTwo::onTouchDown(%this, %touchID, %worldPos)
{
if(sectorOneLevelTwo.touchID $= "")
{
sectorOneLevelTwo.touchID = %touchID;
}
if(sectorOneLevelTwo.touchID $= %touchID)
{
sceneWindow2D.endLevel();
sceneWindow2D.loadLevel("data/levels/multipleWaves.t2d");
}
}

function sectorOneLevelTwo::onTouchUp(%this, %touchID, %worldPos)
{
if (sectorOneLevelTwo.touchID $= %touchID)
{
sectorOneLevelTwo.touchID = "";
}
if(sectorOneLevelTwo.touchID $= "")
{
// release the button
}
}

Thanks in advance.

#1
11/29/2011 (5:07 pm)
@Jack-S-

1) You can encode blocks of code with MarkupLite tags; it helps readability.

2) With so few details is virtually impossible for anyone to see what it's happening; consider sending complete files.

3) Did you try to debug the script? Torsion is very good at this.

4) I did a resource that does what you want to accomplish, a t2dStaticSprite button.

Check it out:

Torque Minimal Template -- Part 5. Levels, sound and ML text

It was done with 1.4.1 but I recently ported it to 1.5 and all works fine, just replace the OnMouse by OnTouch calls and the constants $pref::iDevice:: with $pref::iOS::

hope that hepls :)
#2
11/29/2011 (5:10 pm)
This sounds very related to your other issue in this thread. Is that the case or is this completely separate?
#3
12/11/2011 (12:44 pm)
@ Michael, Hi sorry for my late reply ive been a little bogged down with the day job lately. Both threads are different issues that im having at the momment.

For instance the issue in this thread is just the buttons wont work if placed outside a central area of the screen.

The other issue im having with buttons again.. is that buttons that DO work dont respond when I run the game in iPhone or Iphone4 resolutions.
My hud buttons and various other buttons work perfectly in Ipad mode but if I change the simulation to iPhone or iPhone4 then the buttons are un-responsive.