Be a Supporter!

hitTest problem

  • 198 Views
  • 0 Replies
New Topic Respond to this Topic
flailthefox
flailthefox
  • Member since: Aug. 30, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
hitTest problem 2009-05-05 15:15:08 Reply

just wont work for some reason, all ti does is go right through. here s the example.
File: http://spamtheweb.com/ul/upload/050509/7 2838_theblockgame.swf

the red circle is the character. i made individual sides to the block along with individual instance names. but he goes right through ¬_¬'

here is the code:

onClipEvent (load) {
    var moving:Boolean = false
	var i = 1;
	var xdir = 0;
	var ydir = 0;
    radius = 20;
}
onClipEvent (enterFrame) {
	if (i>0) {
		moving = true;
		i -= 1;
		_x += xdir;
		_y += ydir;
	} else {
		moving = false;
	}
}
onClipEvent (keyDown) {
	if (Key.isDown(Key.UP)) {
		if (moving == false) {
			i = 10;
			xdir = 0;
			ydir = -2.5;
		}
	} else if (Key.isDown(Key.DOWN)) {
		if (moving == false) {
			i = 10;
			xdir = 0;
			ydir = 2.5;
		}
	} else if (Key.isDown(Key.LEFT)) {
		if (moving == false) {
			i = 10;
			xdir = -2.5;
			ydir = 0;
		}
	} else if (Key.isDown(Key.RIGHT)) {
		if (moving == false) {
			i = 10;
			xdir = 2.5;
			ydir = 0;
		}
	}
}
onClipEvent (enterFrame) {
while (_root.blockdown.hitTest(_x, _y+radius, true)) {
        i = 10;
		xdir = 0;
		ydir = 12.5;
    }
    while (_root.blockup.hitTest(_x, _y-radius, true)) {
        i = 10;
		xdir = 0;
		ydir = -12.5;    
	}
    while (_root.blockright.hitTest(_x-radius, _y, true)) {
        i = 10;
		xdir = 12.5;
		ydir = 0;
    }
    while (_root.blockleft.hitTest(_x+radius, _y, true)) {
        i = 10;
		xdir = -12.5;
		ydir = 0;
    }
}

I have tried a lot of things, but they dont make any difference :/

help?


Destroyed.