From Test-Scratch-Wiki

Line 1: Line 1:
{{:Spa:Cambiar x por() (bloque)/translate}}
+
 
 
{{block
 
{{block
 
| name      = Change X by ()
 
| name      = Change X by ()
Line 8: Line 8:
 
}}
 
}}
  
El [[Spa:Bloques|bloque]]'''Cambiar x por ()'''  es un [[Spa:|Motion block]] and a [[Eng:Stack Block|Stack block]]. The block moves its [[Eng:sprite|sprite]] [[Eng:Costume Center|costume center's]] X position by the specified amount. The x axis ranges from -240 to 240.
+
El [[Spa:Bloques|bloque]] '''Cambiar x por ()'''  es un [[Spa:Bloques de movimiento|Bloque de movimiento]] y un [[Spa:Bloque apilableBloque apilable]]. El bloque mueve la posición X del [[Spa:Objeto|sprite]] [[Eng:Centro de disfraz|Centro del disfraz]] por la cantidad especificada. the  El eje X puede variar entre -240 y 240.
  
==Example Uses==
+
==Ejemplos de uso==
 
*Often in games, the player controls a sprite and moves it around {{-}} the '''Change X by ()''' block (and the [[Eng:Change Y by () (block)|Change Y by ()]] block) are very common in this event.
 
*Often in games, the player controls a sprite and moves it around {{-}} the '''Change X by ()''' block (and the [[Eng:Change Y by () (block)|Change Y by ()]] block) are very common in this event.
 
<scratchblocks>
 
<scratchblocks>

Revision as of 14:31, 23 March 2020

Change X by ()
2.0 Change X by ().png
Category Motion
Type Stack

El bloque Cambiar x por () es un Bloque de movimiento y un Spa:Bloque apilableBloque apilable. El bloque mueve la posición X del sprite Centro del disfraz por la cantidad especificada. the El eje X puede variar entre -240 y 240.

Ejemplos de uso

  • Often in games, the player controls a sprite and moves it around — the Change X by () block (and the Change Y by () block) are very common in this event.
when gf clicked
forever
if <key [left arrow v] pressed?>
change x by (-5)
end
if <key [right arrow v] pressed?>
change x by (5)
  • This block can also be used to move a sprite which creates a sine wave (see Trigonometry) along the x axis. An example script of this situation is:
when gf clicked
go to x (-240) y (([sin v] of (-240)) * (100)) //240 is the leftmost position of the stage
clear //clears a previously drawn wave, if it exists
pen down //draws the first point of the wave
repeat (480) //the width of the stage is 480 x coordinates
pen up //so the movement to the next position is not interfered with an unintended, out-of-place line
change x by (1) //the use of the block
set y to (([sin v] of (x position)) * (100)) //the result is multiplied by "100" to expand the amplitude for visual preference
pen down //creates the mark

Workaround

Main article: List of Block Workarounds

This block can be replicated with either of the following codes:

set x to ((x position) + (change))
go to x: ((x position) + (change)) y: (y position)

See Also