Movement on two axes - source
movie- To restart, right-click
and select "restart"
propertysp propertyxVelocity,
yVelocity
onbeginsprite(me)
sp = sprite(me.spritenum)
--initialize velocity x &
y
xVelocity = 5
yVelocity = 1 end
onexitframe() --increment position
sp.loch = sp.loch
+ xVelocity
sp.locv = sp.locv
+ yVelocity end
This script is the same as the last, but now there is
vertical velocity as well as horizontal. Moving an object both
horizontally and vertically produces a diagonal motion.
The variable for vertical velocity starts
with y to indicate it is used for velocity along the
y axis, while xVelocity is the velocity
along the horizontal x axis.
These two parts are the vertical and horizontal
components of the motion. The vertical component is 1
px down, and the horizontal component is 5 px to the
right.
•If vertical velocity is set to zero, how does it
compare with the one-axis example?
With two axes to work with, you can make
the object move in any direction on the two-dimensional
screen (try it!).
So what is the definition of velocity?
It is the change in position over time.