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

#1 2013-04-03 09:42:40

Maibe
New Scratcher
Registered: 2011-07-28
Posts: 6

Smooth Run and Jump while changing costumes

I was wondering how do you make a smooth run and jump script (with gravity) whilst changing costumes while still moving smoothly.

Offline

 

#2 2013-04-03 13:18:11

xlk
Scratcher
Registered: 2013-03-18
Posts: 57

Re: Smooth Run and Jump while changing costumes

it's hard to make a fluent walking animation, you might be better of making one animation for running at full speed, thought it willl look like the character is sliping when walking. Then you would only have to make it switch frames when right/left is held.
the more fluent you want the animations to be with the movement, the more complex the code becomes and more "if ..." blocks are used.
I'd recomend having 3-5 walking frames, and 1-2 air frames (second one for falling, for example).

when gf clicked
forever
 if <not<<[left] key pressed>and <[right] key pressed>>>
  set costume to [1]// only if you have 1 as a standing frame(!)
 end
 if <touching [ground]>
  if < [left/right arrow] pressed?>
   if <(costume #)=[3/5]>//"3/5" as in 3 or 5, last walking frame
    set cotume # to [1/2]//2 if 1 is a standing frame
   else
    next costume
   end
  end
 else
  if <(ys) > [0]>
   set costume to [jump]
  else
   set costume to [fall]
  end
 end
 
   

Offline

 

#3 2013-04-03 13:33:35

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Smooth Run and Jump while changing costumes

xlk wrote:

it's hard to make a fluent walking animation, you might be better of making one animation for running at full speed, thought it willl look like the character is sliping when walking. Then you would only have to make it switch frames when right/left is held.
the more fluent you want the animations to be with the movement, the more complex the code becomes and more "if ..." blocks are used.
I'd recomend having 3-5 walking frames, and 1-2 air frames (second one for falling, for example).

when gf clicked
forever
 if <not<<[left arrow v] key pressed?>and <[right arrow v] key pressed?>>>
  switch to costume [1 v]// only if you have 1 as a standing frame(!)
 end
 if <touching? [ground]>
  if < < [left arrow v] key pressed?> or <[right arrow v] key pressed?> >
   if <<(costume #)=[3]> or <(costume #) = [5]>>//"3/5" as in 3 or 5, last walking frame
    switch to costume [2 v]//2 if 1 is a standing frame
   else
    next costume
   end
  end
 else
  if <(ys) > [0]>
   switch to costume [jump v]
  else
   switch to costume [fall v]
  end
 end
 
   

Fixed.  smile

Regards,

CAA14

Offline

 

Board footer