(Redirected from Glide)

"Glide" redirects here. For the other type of glide block, see Glide () Secs to () (block).
Glide () Secs to X: () Y: ()
glide () secs to x: () y: ()
Category Motion
Type Stack

The Glide () Secs to X: () Y: () block is a Motion Block and a stack block. The block moves its sprite to the chosen x and y coordinates respective to the chosen seconds. A disadvantage of the glide block, however, is that it pauses the script while the sprite is moving, preventing the script from doing other things while the sprite is gliding. Also, a glide can only be interrupted by a stopping scripts block, and the If on Edge, Bounce block will fail to work its intended function while a sprite is gliding.

Example Uses

The block is used whenever a sprite needs to glide - some common uses are:

  • Fish moving in a tank
glide (pick random (1) to (2)) secs to x: (pick random (-240) to (240)) y: (pick random (-100) to (100))
  • Obstacle sprites are created and glide toward the edge of the screen, as in Frogger
when I receive [StartCars v]
set x to (240)
repeat until <(gameOver) = [1]>
    create clone of (myself v)
    wait (3) secs

when I start as a clone
glide (5) secs to x:(-240) y:(y position)
delete this clone
  • Falling objects
set y to (180)
glide (1) secs to x:(x position) y:(-180)
  • A sprite moving to another
glide (1) secs to x: ([x position v] of (Sprite2 v)) y: ([y position v] of (Sprite2 v))

Comparison of the Glide and Move blocks

This script uses the Move () Steps block to steadily move the sprite from the left edge to the right edge in eight seconds.

set x to (-240)
repeat (80)
    move (6) steps
    wait (0.1) secs

This script does the same thing by gliding.

set x to (-240)
glide (8) secs to x:(240) y:(y position)

Gliding with Ease Out Effect

The Glide block moves the sprite in a linear way, meaning that the sprite moves at the same speed the whole time. However, it is fairly easy to replicate the "ease out" effect that is heavily used in graphic design, where the object slows down as it approaches its target.

when I receive [tween v]
repeat until <<([abs v] of ((target x) - (x position))) < [.25]> and <([abs v] of ((target y) - (y position))) < [.25]>>
 change x by (((target x) - (x position)) / (2))
 change y by (((target y) - (y position)) / (2))
go to x: (target x) y: (target y)

Alternatively, the following script can be used, which, as well as doing an ease out effect, allows choosing how long it should take to get to the wanted position. The 200 is the position (In this case, in the X-axis) which the sprite should glide to. The two X position blocks could be replaced by the Y position one if the sprite needs to move on the Y-axis. The number 10 is the number of seconds taken to reach the position multiplied by 10.

when I receive [tween v]
repeat until <(round (x position)) = [200]>
    change x by (((200) - (x position)) / (10))
set x to (200)

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.