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

#1 2012-04-24 14:04:56

Lilhardy94
Scratcher
Registered: 2012-04-12
Posts: 25

moving

how do i create a smooth running where my person changes costumes to look like he is running bt not interfere with other scripts, i cannot make him jump and run at same time unless i push button at exact time

Offline

 

#2 2012-04-24 14:55:01

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: moving

I'm not too sure what you mean by the costume change... do you mean the sprite changes costume for each direction it's running or as it is running it continuously changes costumes? I think you mean the 2nd one and I'll write that script for you.
Make three separate scripts

when gf clicked
forever
if <key [left arrow v] pressed?>
change x by [-10]
end
if <key [right arrow v] pressed?>
change x by [10]
end
if <<key [left arrow v] pressed?> or <key [right arrow v] pressed ?>>
set [running v] to [yes]
else
set [running v] to [no]
end
end
when gf clicked
forever
if <key [up arrow v] pressed?>
repeat [10]
change y by [2]
end
if <not <key [up arrow v] pressed?>>
change y by [-2]
end
end
when gf clicked
forever
if <(running)=[yes]>
next costume
wait [0.2] secs
end
end


http://i46.tinypic.com/ao03lk.png

Offline

 

#3 2012-05-27 18:19:00

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: moving

PhirripSyrrip wrote:

I'm not too sure what you mean by the costume change... do you mean the sprite changes costume for each direction it's running or as it is running it continuously changes costumes? I think you mean the 2nd one and I'll write that script for you.
Make three separate scripts

when gf clicked
forever
if <key [left arrow v] pressed?>
change x by [-10]
end
if <key [right arrow v] pressed?>
change x by [10]
end
if <<key [left arrow v] pressed?> or <key [right arrow v] pressed ?>>
set [running v] to [yes]
else
set [running v] to [no]
end

when gf clicked
forever
if <key [up arrow v] pressed?>
repeat [10]
change y by [2]
end
if <not <key [up arrow v] pressed?>>
change y by [-2]
end
end
when gf clicked
forever
if <(running)=[yes]>
next costume
wait [0.2] secs
end
end

Well that works, but I must say I prefer:

when gf clicked
forever
if <key [left arrow v] pressed?>
 repeat until <not <key [left arrow v] pressed?>>
change x by [-1]
end
end
if <key [right arrow v] pressed?>
repeat until <not <key [right arrow v] pressed?>>
change x by [1]
end
end
It makes it move quite smoothly, and, if you ask me, is totally worth it.
(For the smooth moving, that is)

Last edited by wasabi56 (2012-05-27 19:40:59)


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#4 2012-05-28 17:55:17

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: moving

wasabi56 wrote:

Well that works, but I must say I prefer:

when gf clicked
forever
if <key [left arrow v] pressed?>
 repeat until <not <key [left arrow v] pressed?>>
change x by [-1]
set [running v] to [yes]
end
end
set [running v] to [no]
if <key [right arrow v] pressed?>
repeat until <not <key [right arrow v] pressed?>>
change x by [1]
set [running v] to [yes]
end
end
set [running v] to [no]
It makes it move quite smoothly, and, if you ask me, is totally worth it.
(For the smooth moving, that is)

That fixed script combined with this script,

when gf clicked
forever
if <(running) = [yes]>
switch to costume [first running costume v]
repeat [2]//or however many other running costumes there are minus the first one.
wait [0.01] secs
next costume
end
else
switch to costume [standing v]
end
will fix your problem.


Why are the secret organizations getting all the attention?  mad

Offline

 

Board footer