Game Development Community

cancel(), proper implementation (sholveded)

by rennie moffat · in iTorque 2D · 09/29/2011 (5:13 am) · 4 replies

Hi, I am trying to cancel() a call if, x event....

I am doing it like this... but it is not working.


onMouseEnter()
%this.rotationCommand = $object.rotateTo(%this.angle, %this.rotationSpeed, true, true, false, 0.1);

onMouseLeave()
cancel(%this.rotationCommand);



What am I not getting/doing correct?

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
09/29/2011 (5:17 am)
Rennie, cancel needs a schedule id.

Your %this.rotationCommand is not a schedule id.

I'm not too sure what you are trying to do? To stop the rotation you need to set speed to zero.
#2
09/29/2011 (5:18 am)
Oh, of course!

Thanks Scott.


::))(((
#3
09/29/2011 (8:26 am)
I'll drop a note in here.

Scott mentioned schedule id's which should be a dead giveaway

%this = someObject;
%this.timeInterval = %this.schedule(500, doThis);
//oh wait.. I don't want that
cancel(%this.timeInterval);

This is what the cancel function is for.
#4
09/29/2011 (8:58 am)
Yes, I realized that, as I had read it in the docs, that is was for schedIDs, but for some reason was racking my head as to how to make it stop on event. I thought there might be some universal cancel function I was missing. For some reason that it was rotation, not velocity was getting me? ? ? I dont know. Anyhow, thanks.