PDA

View Full Version : How do I make a simple counter?


general
05-08-2006, 03:25 AM
I'm trying to make a counter of sort with the 3D text. I want it to count the number of times the ball bounced. It's an animation if that helps. So, like when the ball bounce the text will change to 1, another bounce and it will change to 2 etc etc. I only managed to put a line that changes the text to 1 or 2 after a bounce but what if I had 100 bounces? I can't do every single line. I know it has something to do with variable but I can't seem to figure it out. Any help would be appreciated,



Many thanks :)

Jabberwocky
05-09-2006, 07:43 PM
If you'll put a loop around your bounce routine, the loop has a built in index variable. Just set your 3D text to the value of the index variable. You'll need to convert the index variable, it's a number, to a string so you can display it as text in the 3D text object.

I've attached an example. When you save it locally just make sure the extension is ".a2w" not ".zip" and you should be able to open it in Alice.

Have fun!

Chrono
11-28-2006, 09:47 PM
Zip files will play in alice but you have to change the type of file to "All"

jyby
01-30-2009, 02:03 PM
The value is displayed as a real value (e.g. 0.0), even when the counter is an integer.
Is there a way to display just an integer?

(Other than creating many copies of all the digit and managing them as objects to display the digits of the integer at the correct location, which would be a nice exercise in itself, but which would more than double the code length of any other project...)