Coding objects to move using javascript


#1

I would like to create a javascript tutorial for my Year 8 (12/13 year olds) to learn some basic programming concepts such as functions, lists etc. My plan is for them to create an aquarium scene which we will then annotate to analyse the code as they have specific concepts to learn as part of the curriculum. Anyway to my immediate problem - thanks in advance for help…

When I add an object such as a turtle and run the code in the attached picture I would have thought it would have moved. I also tried to createItem() method but this only works for some objects - 3D low poly objects?

Thanks!


#2

Hi Ronan,

Scene must be written with an uppercase S.

var turtle = Scene.getItem('S4W27b8Vr4');

You can catch small errors like this when you switch your editor setting to “TypeScript”.


#3

Classic - school boy error! Thanks so much - I’ll give typescript a whirl - never used it before.


#4

Hi Ronan,

you don’t necessarily need to learn TypeScript when switching to it in the editor. All JavaScript is also valid TypeScript, but it enhances the JavaScript language with all kinds of additional features.