I need a counter for a larger project. I needed help to do it (thanks Paul) so thought I should pass on the technique.
Goal: By clicking on a shape a counter increments
This is for making a large counter, which displays in a specialised text player. Another (easier) way would involve using a detailed watcher but that only has a small display. This method involves learning something about setting variables and using Text so it is has broader application.
Drag a "Text" out of the Supplies flap
Have a look in the Viewer, it has a Text's numeric value tile in the basic category. Click in the value and type a number and that number will appear where the "Text" is
Make a new shape for clicking on. I made a rectangle and coloured it green. I kept the name at the default, "Sketch"
Add a variable to Sketch, I called mine "counter", then change value type to Player. Note that Text types are not available.
So you now have to pass the Sketch counter player variable a text tile. This is how you make a text type.
Make a Sketch script. Then drag Sketch counter by the assignment arrow to the script. The line will read:
Sketch's counter <-- dot Then open the Text viewer. Get it to hand you a "tile representing me" from the menu at the top. Then replace the 'dot' tile with this new 'Text' tile (see diagram)
So, now we have made a counter variable which is of text type!
Make a new Sketch script. I called this script "increment"
Reopen the Text viewer and drag Text's numeric value to the new script by the assignment handle. It will read:
Text's numericValue <-- 0 (just click on the 0.00 and replace it with 0 and the number of decimal places will adjust automatically) Reopen the Sketch Viewer and drag Sketch's counter (not by the assignment arrow) to replace Text's with Sketch's counter (see diagram)
Now modify the code so it reads: Sketch's counter numericValue increase by 1 (see diagram)
You can modify the Events which trigger the code by clicking on the "normal" button:
I changed mine to mouseDown, so I can increment the number by clicking on the green shape which is named Sketch.
Project available: http://www.users.on.net/%7Ebillkerr/etoy/counterByOne.005.pr
The market paradigm versus the production paradigm - from Robert Wade Why have the large majority of professional economists, especially in the academy and in western-dominated international organizations lik...
1 hour ago