Estimated Time: 15 minutes Difficulty: Easy
- Create an account or login to CoSpaces.
- Create a new Space.
- In the upper right hand corner, click on the Code icon.
We can do all sorts of things in CoSpaces. In this simple example, we’ll move a person whenever someone touches him or clicks on him. We drag and drop a person from the Library onto the Scene. Then we need to assign it with a name. Click on the icon that looks like a tag and type in a name. In the example below, I used the name redperson. Hit enter to save the name. We can use this name in our code now.
In this coding example, we’ll use the Blockly scripting language (an easy to understand drag-and-drop coding interface). Click on the Blockly tab in the Code panel.
We can now drag and drop various puzzle shaped coding blocks. In the Events section, I’ll drag the “on activate of” block.
“On Activate of..” is an Event that waits for something to activate (or touch/click on) an object. We’ll make it so that whenever the redperson is activated, he will move. Drag and drop the “move” block and snap it to fit inside the green block.
In this example, the redperson will move one meter forward in one second.