onPositionTarget callback: Proper implementation [SOLVED]
by Brian Szatkowski · in iTorque 2D · 08/24/2010 (4:29 pm) · 2 replies
Hi All;
I have a set of objects instantiated and added to the scene graph, via an iteration, as:
Each of these objects then has the capability of being moved (based on variables and gestures used). Here is an example of one such movement snippet:
Now, I'm trying to prevent the user from initiating another move until the previous movement has completed (i.e. the last piece triggered to move has reached its destination). What I'm having a problem with, however, is getting the callback for moveTo (onPositionTarget) to work.
Everything exists on the same sceneWindow2D scene graph.
This is what I had implemented but it is never triggered:
I've added/removed the UseUpdateCallback on the scene itself, added/removed UseUpdateCallback on the object itself (which I don't even know whether it is proper), and rubbed my rabbit's foot. Alas, nothing seems to be working.
I'm hoping that I'm just having an off day and have simply mis-implemented this. Any feedback is greatly appreciated.
Thank you!
I have a set of objects instantiated and added to the scene graph, via an iteration, as:
$piece = new t2dStaticSprite(%addPiece) {
imageMap = "dynamicImageMap";
frame = (%i - 1);
mUseSourceRect = "0";
sourceRect = "0 0 0 0";
canSaveDynamicFields = "1";
UseMouseEvents = "1";
Position = "-120.000 -200.000";
size = $dimensions;
Layer = "1";
BlendIgnoreTextureAlpha = "1";
UsesPhysics = "1";
//UseUpdateCallback = "1";
AutoMassInertia = "0";
Mass = "64";
Inertia = "68266.7";
mountID = (%p + 1);
};Each of these objects then has the capability of being moved (based on variables and gestures used). Here is an example of one such movement snippet:
%currentPiece.moveTo(%startX, (%startY - $gridCellSize), $speed, true, true, true, 0.1);
Now, I'm trying to prevent the user from initiating another move until the previous movement has completed (i.e. the last piece triggered to move has reached its destination). What I'm having a problem with, however, is getting the callback for moveTo (onPositionTarget) to work.
Everything exists on the same sceneWindow2D scene graph.
This is what I had implemented but it is never triggered:
// Callback for when a piece has successfully moved to its next position
function sceneWindow2D::onPositionTarget(%this)
{
echo ("onPositionTarget callback called!");
// Reset pieceMoving so new touch-moves can be registered
$pieceMoving = 0;
}I've added/removed the UseUpdateCallback on the scene itself, added/removed UseUpdateCallback on the object itself (which I don't even know whether it is proper), and rubbed my rabbit's foot. Alas, nothing seems to be working.
I'm hoping that I'm just having an off day and have simply mis-implemented this. Any feedback is greatly appreciated.
Thank you!
About the author
Torque Owner Johnny Vo
Or you can call it for each class. e.g. ClassFOO::onPositionTarget(%this)