This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-13 15:24:57

bobbyjenks
New Scratcher
Registered: 2011-04-13
Posts: 4

move object

How do you move an object up down and diagonally

Offline

 

#2 2011-04-13 15:35:53

Clank23
Scratcher
Registered: 2011-03-01
Posts: 1000+

Re: move object

up=change y by:
down=change y by:-
right=change x by:
left=change x by:-
hope this helps!

Last edited by Clank23 (2011-04-13 15:36:23)


http://img846.imageshack.us/img846/4333/signaturely.png

Offline

 

#3 2011-04-13 16:27:09

bobbyjenks
New Scratcher
Registered: 2011-04-13
Posts: 4

Re: move object

Thanks

Offline

 

#4 2011-04-13 16:33:55

bobbyjenks
New Scratcher
Registered: 2011-04-13
Posts: 4

Re: move object

when an object is on a particular x and y (ex. x=-92, y=102), how do i hide or show that object

Offline

 

#5 2011-04-13 16:51:15

Shadowed1
Scratcher
Registered: 2010-01-19
Posts: 100+

Re: move object

bobbyjenks wrote:

when an object is on a particular x and y (ex. x=-92, y=102), how do i hide or show that object

if<xposition =|92|> and <yposition = |102|>
hide

Hope that helps  smile


*Insert some witty, funny or sarcastic comment here*

Offline

 

#6 2011-04-15 14:23:16

dudymate
Scratcher
Registered: 2011-01-07
Posts: 95

Re: move object

<when green flag clicked> <forever> <change x by(10 <change y by(10

Offline

 

#7 2011-04-15 15:19:42

TheWolfyOne
New Scratcher
Registered: 2011-04-14
Posts: 13

Re: move object

To move an object upwards, add a number to the Y position. For example:

[blocks]<when[ up arrow ]key pressed>[/blocks]
[blocks]<change y by( 10[/blocks]

To move an object downwards, subtract a number from the Y position.

[blocks]<when[ down arrow ]key pressed>[/blocks]
[blocks]<change y by( -10 [/blocks]

Here are the equations for making an object move diagonally.

X pos. - 10, Y pos. + 10 (North-west)
X pos. + 10, Y pos. - 10 (South-east)
X pos. + 10, Y pos. + 10 (North-east)
X pos. - 10, Y pos. - 10 (South-west)

You can change the number 10 to any number you wish. If you use a small number such as 5, the object won't move very far, but if you use a big number like 50, it will move very far. The number 10 makes it move an in-between sort of distance.

If you want a sprite to move in a certain direction after pressing the arrow keys, or something like that, you need this script:

[blocks]<when[ left arrow ]key pressed>[/blocks]
[blocks]<change x by( -5 [/blocks]

If you want the sprite to go to a certain spot on the screen after pressing a button, receiving a message, etc., you'd use the "go to" block.

[blocks]<when[ cake ]clicked>[/blocks]
[blocks]<go to x sad  pos. of cake )y sad  pos. of cake [/blocks]
[blocks]<say[ DON'T TOUCH THAT! [/blocks]

However, this block will just make the object "teleport" to the location mentioned. In other words, it will just suddenly appear wherever you told it to go.

If you want it to look like it actually moved over to that place, you should use the "glide" instruction. Here is a script for making a sprite "fly" over to a certain place on the stage.

[blocks]<when I receive[ lift off[/blocks]
[blocks]<glide( 1 )secs to x sad  2 )y sad  142[/blocks]

The more seconds you choose, the slower the sprite will glide. So, if the sprite was a rocket, like in the above example, you would type in 1 second or less. (Yes, you can do decimal numbers.) If the sprite was a tractor, you would choose something around 10 seconds.

I hope this information helped you with whatever project you're working on, and I hope it will be useful for your future projects too. Happy Scratch-ing!  smile

Offline

 

Board footer