Allowing a condition, only if...
by rennie moffat · in Torque Game Builder · 02/02/2010 (10:22 pm) · 4 replies
I have this behavior. How it works is that it is a button which, onMouseUp, triggers the dismounting of another object. The trick is I only want the dismount call to work, ONLY if the said other object IS mounted. If it is not mounted, I want the dismount, onMouseUp to not work.
function starDismountBtn::onBehaviorAdd(%this)
{
%this.owner.enableUpdateCallback();
}
function starDismountBtn::onUpdate(%this)
{
%this.checkStarMount();
}
function starDismountBtn::checkStarMount(%this)
{
%starIsMounted = %this.star.getIsMounted();
if(%starIsMounted == flase)
return;
%this.owner.setUseMouseEvents(true);
}
function starDismountBtn::onMouseUp(%this, %modifier, %worldPos)
{
%this.star.dismount();
%this.star.setConstantForceY(%this.gravity);
}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.
#2
false is misspelled. Why not just use !%starIsMounted
or
02/03/2010 (4:01 am)
if(%starIsMounted == flase)
false is misspelled. Why not just use !%starIsMounted
or
if(%starIsMounted) %this.owner.setUseMouseEvents(true);
#3
I actually had it as true then just changed it.
but in theory I am on the right track.
Thanks guys.
02/03/2010 (10:40 am)
ooops. I actually had it as true then just changed it.
but in theory I am on the right track.
Thanks guys.
#4
02/03/2010 (10:51 am)
Ok great, I just got it, added in if false and if true statements. and it works fine. Amazing what a god sleep will do.
Torque Owner Shaderman