
A variable is a way of storing data used in a the project. Let's go through it and explain how it works.įirst, we're using two variables - here named "OldX" and "OldY".

This is the entirety of the script that takes care of it:

Explore the Controller menu for ||controller:move mySprite with buttons|| and select the plus sign in the block to see ||controller:vx 100 and vy 100||.Start with motion (short method) example above or similar code.Create the sample code and run the codeĬ(ControllerButtonEvent.Pressed, function () ) Student Task #3: Create Velocity Motion.Create a new project and name it “motionLR”.Short methods and functions with motionĮxample #1: Increment position left and right.Setting ||sprites:vx|| and ||sprites:vy|| velocity.Incrementing ||sprites:x|| and ||sprites:y|| coordinates.


In these activities, the student will use: When the velocities of a sprite are not zero, then the sprite will be in motion. Velocity is the rate of change of our position - in real life, this is often measured as kilometers per hour or miles per hour. We will also see how to give a sprite a speed of motion, or velocity. We can use those events to change sprite location, and to make the sprite move. The game pad has ||controller:controller events|| for the ||controller:up||, ||controller:down||, ||controller:left|| and ||controller:right|| buttons. To get sprites moving, we will change their position using a game pad event.
