itween scaling issue

Hi there,
I have been using iTween recently and it’s Great! But I am having this one issue that seems to pop up a bit, just wondering if anyone here knows a good workaround…

I’m using itween to punchscale a button when the user presses and releases it. The problem is that if the user releases the button before the “press” punchscale animation finishes, the “release” punchscale animation starts from whatever scale the button is at in that moment, so if generally ends up getting bigger over time.
I tried to put something like this before the iTween script to make it reset the scale of the button but it didn’t really work quite right.

LeftButton.transform.localScale = Vector3(1,1,1);//Reset the scale       
iTween.punchScale(LeftButton,{"amount": Vector3(-.3,-.3,-.3), "time":1.6});

Does anyone with some iTween experience know how to get around this issue?

Thanks
Pete

I’m sorry I never got back to your email; life has been busy and I’m really trying to get iTween 2.0 done, take care of my pregnant wife, the insane amount of home improvement projects… ok I’ll stop complaining.

Have you considered using an ‘onStart’ callback that resets the scale when each iTween is run? I think I may have left a bug or two in iTween 1 that causes it to not grab the correct ‘current’ values when an iTween starts and that may be why your reset attempt isn’t working.

Let me know if the callback solution doesn’t help.

Hi there,
Hey no worries, thanks for the reply.

Just not too sure how to use those callbacks in this context.

iTween.punchScale(LeftButton,{"amount": Vector3(-.3,-.3,-.3), "time":1.6});

would you run a reset scale function from the “onStart” callback?

Yup!

iTween.punchScale(LeftButton,{"amount": Vector3(-.3,-.3,-.3), "time":1.6, "onStart":"resetScale"});

function resetScale(){
 //reset the scale here.
}

Clearer?

BTW, I TOTALLY want some of your stickers!!

Ha! Thanks :slight_smile:
I’ve been too busy on this game to get a chance to cut some more! I’d better get around to it soon…

Hey that worked! Also pretty handy to know about those callbacks now.

Thanks again!

Hi Pixelplacement1, I’ve been trying to use the callback functions but it’s not working for some reason. My code is like this:

if (GUI.Button (Rect (20,160,160,20), "Blackboard"))
 { if(!iBBoard) {
	blackboard.active = true;
	iBBoard = true;
	iTween.ScaleFrom(blackboard,{"scale":Vector3(-0.4,-0.5,1),"ignoretimescale":true, "time": 0.5, "easetype": "spring", "onStart": "resetScale"});
}

function resetScale() {
		print("Hello");
		blackboard.transform.localScale = Vector3(1,1,1);//Reset the scale
	}

It doesn’t even the print the Hello string. It means it’s not going through the function right? Wondering if I’m missing anything.

Hope you can help.

Thanks.

Shouldn’t it be “onstart” instead of “onStart”? Or does case not matter?

I was thinking the same thing before so I’ve tried both…and it still doesn’t work :frowning:

Never mind, I always seem to get it working myself after posting it in the forum. the onstart function that calls for resetScale, i had to put the function in the object itself. :stuck_out_tongue:

Thanks again.

Glad you figured it out. You can also use iTween’s “onStartTarget” to tell it which object contains the function.

P.S. I designed iTween for maximum usability - that said you can use any capitalization you want. Even this is valid: “OnStArT” :wink: