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

#1 2011-03-05 11:38:54

mtsa
Scratcher
Registered: 2010-12-09
Posts: 1

HELP with the hitTest

Hi, im not that new, but im currently working on a scratch project where my HitTests dont work!!! help!!!

Offline

 

#2 2011-03-05 19:19:02

kingofdallamas
Scratcher
Registered: 2010-03-07
Posts: 500+

Re: HELP with the hitTest

Hmm, can you further explain what specifically is wrong with the hitTests?
Well, first you must have the main sprite and the sensor sprite which forever follows the main sprite with its sides broadcasting certain hittests to the main sprite. Make each side of the sensor sprite to have different colors, when that color is touching the color that is the platform, change hit rigght test by one for example.

Hit right test shall be a variable.
Xvelocity will be set as x.
Hit test left will also be a variable.
Gravity set as y.

The main sprite will then have the script as this:
When green flag clicked
<forever> <if> hit right test =1, change xvelocity by -4, set hit test left to 0
<if> hit test left=1, change xvelocity by 4, set hit test leeft to 0.
<if on edge, bounce>
<if else touching color <whatever color platform bottom> set gravity to .2 <if touching whatever color platform top>set gravity to -1
<forever> change gravity by -0.2
if <key up arrow pressed and touching color <whatever color platform bottom>
set gravity to 4.3
change y by Gravity
if else key right arrow presssed
move five steps right
set xVelocity to 5
if else key left arrow pressed
move five steps left
set xVelocity to -2.5
set xVelocity to 0
change x by xVelocity

I hope you understand my scripting! If you need more help, don't be afraid to ask and look at the Scratch Wiki.

If you want acceleration, the scripting would be different, and whatever variable that uses <x> will have this: change x by *3.18
Sorry if I wrote something wrong with the scripts.  tongue

Last edited by kingofdallamas (2011-03-05 19:19:45)


http://i853.photobucket.com/albums/ab99/Gilgamesh1192/Ninja%20Saga/ElementalJutsus2.gifhttp://i27.photobucket.com/albums/c192/BoomKaTish/GIF/thgfhgfhfhgf.gif
ハロー友だち!

Offline

 

Board footer