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

#1 2008-10-03 20:11:11

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

WHAT is this?????? (for nerdy programmer types)

Honestly i quietly debated the fact of not putting it in FAQ(people dont leave actionscript FAQs in that, wow, I almost typed in french there, putting in 'Dans' instead of in(creepy) school is getting to me. also not putting in the popular all about scratch section was obvious. Oui, j'aime le fromage. if anyone who doesnt live in canada can tell me what that means, Ill make them a logo with the meaning of that sentence, oh almost forgot, the script
onClipEvent(load) {
    var dir:Number = 5;
    var spd:Number = 5;
}
onClipEvent(enterFrame){
   if(_parent.egobject.hitTest(_x, _y, true), Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT)){
      gotoAndStop(2);
   } else if (_parent.egobject.hitTest(_x-20, _y, true)) {
      gotoAndStop(3);
   } else if (_parent.egobject.hitTest(_x+20, _y, true)) {
      gotoAndStop(4);
   } else if (_parent.egobject.hitTest(_x, _y-20, true)) {
      gotoAndStop(5);
   } else if (_parent.egobject.hitTest(_x, _y+20, true), Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT)) {
       dir = (Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT))
          
   } else {
     dir = (Key.isDown(Key.RIGHT)-Key.isDown(Key.LEFT))
        _x += dir * spd;
   }
}
Yes, this is my script, its basically the same as
Forever if touching 'blah' and 'blah' pressed,
repeat 5 times
move blah - blah times two steps
end forever
but Its just an edit of another of  my scripts but its not working for a platformer hit test yet.


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#2 2008-10-03 20:45:17

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: WHAT is this?????? (for nerdy programmer types)

Umm your post isn't really clear so I can't tell what you want.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2008-10-05 15:34:57

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: WHAT is this?????? (for nerdy programmer types)

Well, part of this (I think) is supposed to make be an  object hit test to stop it from moving when it hits something, Its not working, I dont know why.


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#4 2008-10-05 16:48:53

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: WHAT is this?????? (for nerdy programmer types)

Wait, did you code this yourself? What are you using it in?

No part of this code will make the MC stop moving when it hits something.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2008-10-06 06:31:13

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: WHAT is this?????? (for nerdy programmer types)

Thats honestly what I thought, I just figured out how to make a movie clip move. I then tried to figure out hit tests, I really had no clue what i was doing umm this is in actionscript 2.0.


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#6 2008-10-06 13:14:22

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: WHAT is this?????? (for nerdy programmer types)

Some advice, don't use code if you don't know how it works.

But on to your hitTest question. There are 2 kinds of hitTests, basic and shapeflag

//this is a basic hitTest
if (_root.wall.hitTest(this)){
trace("you hit a wall");
}

This script will check to see if the MC is touching the wall MC. This hitTest doesn't use the actualy sprites to test, but rather the blue boxes that appear when you click an MC.

// If you hit a wall on the right side get out of the wall.
while (_root.wall.hitTest(_x+(_width/2),_y,true){
// move the MC out
_x--
}

This script will make it so you cannot pass though the wall MC on the right side. You will need a version of this side for every side you do not want to pass through.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#7 2008-10-11 07:28:45

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: WHAT is this?????? (for nerdy programmer types)

Thanks, I think that'll help a bit.


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

Board footer