(Redirected from Glide () Secs to X: () Y: () (block))

"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
Introduced in 16Dec06 (0.x)

The Glide () Secs to X: () Y: () block is a Motion Block and a stack block. The block moves its sprite to the specified x and y coordinates, respective to the specified number of seconds. This block will not stop execution until the specified seconds gave passed, unless it is interrupted by a Stop () (block) block or by the Stop Sign.

Example Uses

Some common uses of this block are:

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

when I start as a clone
show
glide (5) secs to x:(-240) y:(y position)
delete this clone

Workaround

Main article: List of Block Workarounds

The following script can be used as a workaround for this block:

set [speedx v] to (((x) - (x position)) / ((secs) * (30))
set [speedy v] to (((y) - (y position)) / ((secs) * (30))
repeat ((secs) * (30))
change x by (speedx)
change y by (speedy)

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))
end
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 (target x:: variables) variable is the position 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 (time:: variables) variable is the amount of time taken to reach the position, with a higher number taking longer.

when I receive [tween v]
repeat until <(round (x position)) = (target x:: variables)>
    change x by (((target x:: variables) - (x position)) / ((time:: variables) * (10)))
end
set x to (target x:: variables)

See Also

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