Game Development Community

onTouchEnter()?

by rennie moffat · in iTorque 2D · 10/03/2011 (11:34 am) · 7 replies

In the new onTouch System, I am being led to believe that onTouchEnter() does not work. Is this the case? If so, is there a way we can change that?


About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
10/03/2011 (1:26 pm)
Kinda desperate here. If I can not get the onEnter and leave commands to work. my current control system for my current project is knocked.


#2
10/04/2011 (8:29 am)
@staff. No luck on this?

I do not know how you would go about making it so, but it does not seem implausible. Can some one address this please??? Is it not just like flipping a switch somewhere??? Come on guys, help a bruhddah out.



edit;
@Staff.
I have found a work around. However, I would still prefer to use onTouchEnter and onTouchLeave calls. If there is a way to do this. please pass on knowledge.
cheers.
#3
10/04/2011 (11:48 am)
@rennie

you should seriously consider getting a dedicated Windows machine with Torsion :-)

when I started doing Torque I did not know Torque script and I had to do it on a Mac; so it was very frustrating, 90% of the time , my code did not do what I was hoping to and I had no idea why; the debug was by print by print stataments.

then I found out about Torsion, and it was a life saver. I cannot even imagine anyone doing Torque script without it.

my way of working is
1) develop on windows using Torque
2) have a version control svn based linux server to commit over the internet
3) check out from the Mac and deploy to device

so, we're looking at 3 machines here, but on the long run it pays up. (you can get away with 2, put the server on one of them; I like to keep the server at home and travel with the other 1 or 2)

other thing: never update a version (1.4 to 1.5 ) in the middle of game development; specially if you don't have the code in version control

I did not change yet to 1.5, I am still in 1.4.1; it works for me and has all the features that I want (some did by myself :-) , that are now in 1.5 )

hope that helps
#4
10/04/2011 (12:28 pm)
I echo what Pedro said about never updating during development. I'm still on 1.4.1, Xcode 3 and Snow Leaopard and running iOS4 on my devices,
#5
10/04/2011 (6:04 pm)
@Pedro & @Scott
Yes, that would be nice to work across three computers for ease, however, for now, I am just stuck on my iMac. Which is fine for me as I know no different.

As far as my project goes, I actually just began a new one last week. So the release of 1.5 was purely coincidental. So, thanks for that GG. Our timing, could not have been better.

This issue for me is, and maybe you can answer it, is that with the new touchDrag behavior GG gave us, we have a new function ( as far as I can tell ), onTouchDown, onTouchUp and onTouchDrag. Are these programmed by GG? See, my question is that are these functions, some how recognized by the gui? My comparison would be that if I created my own function onFingerDown() I am not sure the gui would recognize that I mean "that when a finger touches the screen.. do this...validate the function". So, if that is the case, why could GG not program a function onTouchLeave, and onTouchEnter()?




#6
10/04/2011 (7:05 pm)
sorry, Rennie, I do not know the answer to that question, I did not try 1.5 and the new touch system yet; eventually I will port all my code to 1.5; I never actually used any Touch functions in 1.4.1, I used only the OnMouse functions (down, up, drag);
#7
10/04/2011 (7:17 pm)
Well, one method that have used (they have used two) to create a multiple drag object system..
1. a behavior they ship with 1.5. In it, is this....
//-----------------------------------------------------------------------------
// Torque
// Copyright GarageGames, LLC 2011
//-----------------------------------------------------------------------------

// Create this behavior only if it does not already exist
if (!isObject(TouchDrag))
{
   // Create this behavior from the blank BehaviorTemplate
   // Name it TouchDrag
   %template = new BehaviorTemplate(TouchDrag);
   
   // friendlyName will be what is displayed in the editor
   // behaviorType organize this behavior in the editor
   // description briefly explains what this behavior does
   %template.friendlyName = "Touch Drag";
   %template.behaviorType = "Movement Styles";
   %template.description  = "Allows the user to drag the object using the touch screen";
}

function TouchDrag::onBehaviorAdd(%this)
{
   %this.touchID = "";
   %this.owner.setUseMouseEvents(true);
}

function TouchDrag::onTouchDown(%this, %touchID, %worldPos)
{
   // If we are already dragging, do nothing
   // Otherwise, enable the drag variable
   if(%this.touchID $="")
   {
      %this.touchID = %touchID;
   }
}

function TouchDrag::onTouchUp(%this, %touchID, %worldPos)
{
   if(%this.touchID $= %touchID)
   {
      %this.touchID = "";
   }
}

function TouchDrag::onTouchDragged(%this, %touchID, %worldPos)
{
   if(%this.touchID $= "")
      %this.touchID = %touchID;
      
   if(%this.touchID $= %touchID)
   {
      %this.owner.setPosition(%worldPos);
   }
}

As you can see, there is a new set of functions. Somehow, the owner recognizes when I touch down on the it. This, via onTouchDown() etc, etc etc.



So my question is, how does the owner know that it has been touched by simply stating function onTouchDown()? To add to that, IF, this was created and is somehow special more so than if I just randomly created a function called onFingerDown(), I can pretty much guarantee the owner, will not know I want something to happen when I put my finger down on it. So.. how did they do that?