(Redirected from Go to X: () Y: ())

Go to X: () Y: ()
go to x: () y: ()
Category Motion
Type Stack
Introduced in 14Feb04 (0.x)

The Go to X: () Y: () block is a Motion Block and a Stack Block. The block sets its sprite's X and Y position to the specified amounts. This block is related to the Set X to () and the Set Y to () blocks — it is the same as the two blocks combined, as shown in the workaround.

This block has no animation in its movement — it is the simplest way to move a sprite around the screen without displaying any animation (i.e. gliding). Therefore, this block is used whenever a sprite needs to jump to another spot.

Example Uses

Sprites often have to jump to places — this block is the simplest way to do so.

Some common uses for the Go to X: () Y: () block:

  • Moving a sprite
go to x: (73) y: (84)
  • Resetting the sprite's position at the beginning of a project or stage
when gf clicked
go to x: (73) y: (84)
when I receive [Stamp picture v]
switch costume to (Background v)
go to x: (73) y: (84)
stamp
next costume
go to x: (83) y: (114)
stamp
next costume
go to x: (95) y: (144)
stamp

Workaround

Main article: List of Block Workarounds

This block can be replicated with the following code:

glide (0) secs to x: (X amount) y: (Y amount)

Alternatively, these two blocks can also replicate the block:

set x to (X amount)
set y to (Y amount)

Note that this workaround is not a perfect workaround while using the pen, as the difference in the Sprite's motion can affect the pen's drawing. This difference can be demonstrated with these two scripts:

when [a v] key pressed
pen up
go to x: (0) y: (0)
pen down
go to x: (100) y: (100)

when [b v] key pressed
pen up
go to x: (0) y: (0)
pen down
set x to (100)
set y to (100)

The first script will cause the pen to draw a diagonal line (shown in blue), while the second script will cause the pen to first draw a horizontal line before drawing a vertical one (shown in red):
Go-To-X-Y-Pitfall.png

See Also

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