Counting successive bounces with?
by Jon Mitchell · in Torque Game Builder · 03/19/2007 (8:54 pm) · 2 replies
Say I have "wall" as an object and I throw a ball at the wall. Is there a way to count three successive bounces, but reset the count to zero should only one or two bounces happen and not the full three in a row?
I tried to use onCollision, but contact count if I under stand only returns the value of how many objects it makes contact at one time and contacts only gives out coords to the point of contact, so I think onCollision will not help, so I thought maybe I could pick everyone's collective brain :-)
One though I did have was to use an if statement so every time the ball made contact it would just increase a counter then when three was reached set a short timer and then kill the ball, however if a person takes a bunch of single throws with one bounce each, the third throw will be off because there were not successive bounces.
I tried to use onCollision, but contact count if I under stand only returns the value of how many objects it makes contact at one time and contacts only gives out coords to the point of contact, so I think onCollision will not help, so I thought maybe I could pick everyone's collective brain :-)
One though I did have was to use an if statement so every time the ball made contact it would just increase a counter then when three was reached set a short timer and then kill the ball, however if a person takes a bunch of single throws with one bounce each, the third throw will be off because there were not successive bounces.
Associate David Higgins
DPHCoders.com
When it collides with something else, or whatever your logic is ... set it back to 0 ...
new t2dStaticSprite(Ball) { class "bouncingBall"; imageMap = "ballImageMap"; frame = 0; size = "12 12"; position = "0 0"; hitWall = 0; }; function bouncingBall::onCollision(.....) { if(%dstObj.ClassName $= "wall") { %srcObj.hitWall++; if(%srcObj.hitWall >= 3) { // do something special } } else { %srcObj.hitWall = 0; // start all over again } }Something like that ...