Thursday, 2 May 2013

TweenJS: Changing Text

This isn't really tweening, just looping a text change.


Line 13: Because the text is center aligned, if you were to set its x property to 0, you would only see half the text.

Line 18: I have made the outline of the rectangle, and have not filled it in. I have also used to getMeasuredWidth/Height() to get the rough dimensions of the text - although what I really need is the dimensions of the text I will change it too, oh well...

Lines 19 and 20: Just positioning the box so it will be around the text.

Line 25: Changes the text after 1 second, no tweening involved. set() is used to change a property of the box, if you don't say which object is supposed to be affected, it assumes it is the object of the tween. Also, wait() is used because otherwise it loops back to the beginning so fast, you can't see the change. Please note, that the highlight box doesn't change back to invisible, this is because the original invisible setting is not part of the looping tween.

No comments:

Post a Comment

Please enter your message here...