In order to get the width of a text field you have created, you are supposed to use:
txt.getMeasuredWidth();
I was trying to add line breaks, EaselJS doesn't support html tags, so I used the \n line break, which works.
Problem? Now getting the measured width doesn't work (although height is fine). In fact, the more line breaks you add, the wider it thinks the text box is!
For myself, I am going to print out my longest line, and measure it's width, then replace it with the full text.
A diary about programming problems - to help me more easily learn from (and Google) past mistakes.
Wednesday, 15 May 2013
EaselJS: Text width
Tuesday, 14 May 2013
TweenJS: Motion Guides
This one uses the MotionGuidePlugin. Apparently, this isn't as straightforward as adding the script as a source, you also have to sort of install it...
Line 14: This is how you 'install' the motion guide plugin
Line 26: I've drawn this line to show the path that the ball will be taking, and how it relates to the motion guide. For the curveTo, the first parameter sort of shows which direction the curve should head towards, the second parameter shows where the curve should end up.
Line 21: The example uses true in the third parameter (the plugin data), but when I set it to false, this still works...
Line 22: The path has six parameters, 1 and 2 are the x,y coordinates of where the object should start. 3 and 4 are the x,y coordinates of where the path should curve towards. 5 and 6 are the x,y coordinates of where the object should end up. Orient is whether or not you want your shape to turn as it moves along its path.
Subscribe to:
Posts (Atom)