Game Development Community

Buttons / Gui

by Zeinad · in iTorque 2D · 04/06/2009 (4:54 pm) · 4 replies

I am currently working on the player interface for my game, and I am running into a few problems. I had been inputting using arrow keys until today (finally got a working mac with which to run the game in the simulator) so I am trying to convert my controls over to a gui format in which the player pushes buttons. I have my gui buttons all set up, however there are two problems.

The first is when I was using arrow keys I had a function that passed a value, 0 or 1 based on if the key was up or down (pretty standard I think) however when I click the gui button it excecutes its command when I click it and nothing when I let it up, so I can pass the 1 with no problem but have no way to set the value back to 0.

The second problem I have is I am going to need my gui to somehow accept having multiple buttons pressed at the same time. It is my understanding from reading some other things on the forums here that this may be somewhat difficult to achieve, and I am not sure how to accomplish it.

#1
04/06/2009 (10:31 pm)
Multi-touch is fundamentally broken, wait for the fix, which would probably come after North Korea has perfected their Taepodong missiles.
#2
04/06/2009 (10:43 pm)
Ouch. Or maybe when Iran finally shuts down their centrifuges. Ee might be exaggerating a little bit, but I won't disagree with him.

Seems like GG cashed in on the developers who wanted to make games for the iPhone by doing a quick and incomplete port of TGB (iTorque costs twice as much as a Pro license of TGB). iTGB works if you have experience with working with TGB (or if you already have a completed project and want to do a simple port), but in it's current state, in my opinion it is incapable of allowing developers to create an iPhone specific project using the device's unique features (multitouch, camera, access to cellular network, etc.) from the ground up without jumping through a million flaming hoops. I'm not saying it's impossible, but it's so unintuitive, might as well be (just look at the thread on how to implement the popup keyboard!). I have a few threads which remain unanswered to this day, and I'm not sure where to get answers to basic questions, like making a simple GUI level loader, and so forth. I'm primarily a designer, although I have a lot of experience working with code, I want to stay away from code as much as I can, so I can focus on the most important part of making games: the design!

I was at GDC '09 and personally spoke with Deborah and Michael, but neither of them could give me a concrete release date for 1.2, which from what I hear, should make all our lives easier and happier.

That said, I remain optimistic about TGB, and I'll persevere.

Apologies to OP for posting this rant.
#3
04/07/2009 (5:57 am)
No problem, its nice to get varied perspective on things.

I am primarily a programmer/scripter, however when it comes to torque I prefer to keep things out of the engine when possible. That being said I haven't been able to get the multi-touch example from the iTGB cheat sheet to work at all yet, not sure what I am doing wrong I'll be messing with it a little more today. Even if I get it working however, I realized I have another problem (in addition to the first two above) which is: How do I test multi-touch in the simulator? or in game when run in torque?

I hope one or the other is possible or else my workflow for testing to see if I have multi-touch working and any bug fixing that is needed after that will be painfully long and involve two computers.
#4
04/07/2009 (1:38 pm)
Zeinad, about the iPhoneTest project that GG included with iTGB 1.1, if you run the .td2proj within Torque Game Builder, it will compile, and you will find that it will run with the 2 buttons (Bounce & Gravity) working perfectly.

However, the iPhoneTest project has multitouch and accelerometer implementations which you won't be able to see in action, unless you make a build using Xcode, so you have to port this project to the iPhone to see 100% of it.

Regarding some multitouch functionality, here's that code that detects touches, and passes it onto the system for further functions:

function oniPhoneTouchDown( %touchCount, %touchX, %touchY ) {

   for( %i = 0; %i < %touchCount; %i++ ) {
      %screenPos = getWord( %touchX, %i ) SPC getWord( %touchY, %i );      
      %worldPos = sceneWindow2D.getWorldPoint( %screenPos );

      if( $numBalls < $maxBalls ) {
         createBall( %worldPos );
      }
   }
   if( $CurrentMode $= "Bounce" ) {
      TextCtrl1.setText( "Images:" SPC $NumBalls );
      TextCtrl2.setText( "Touches:" SPC %touchCount );
   }
}
The 2 GUI buttons "Bounce" and "Gravity" control the global variable "$CurrentMode". Depending on what $CurrentMode's value is, objects within the scene either bounce around arbitrarily, or gravitate towards wherever "down" is. Playing around with the test project, the cheat sheet thread is right in saying the first touch is interpreted by the engine as an onMouseDown() event.