-
IT'S GON' RAIN !!!
[help] really stuck, why is this not working!!
hi,
here is my code i am using on my game character:
code:
onClipEvent (enterFrame) {
if(Key.isDown(Key.LEFT)) {
this._x -= 5;
_root.alicemc.gotoAndPlay("left");
}
if(Key.isDown(Key.RIGHT)) {
this._x += 5;
_root.alicemc.gotoAndPlay("right");
}
if(Key.isDown(Key.UP)) {
this._y -= 5;
_root.alicemc.gotoAndPlay("up");
}
if(Key.isDown(Key.DOWN)) {
this._y += 5;
_root.alicemc.gotoAndPlay("down");
}
if(Key.isDown(Key.SPACE)) {
_root.alicemc.gotoAndPlay("chop");
}
x = this._x;
y = this._y;
if(!_root.land.hitTest(this._x+x,this._y+y,true)) {
_x += x;
_y += y;
}
}
onClipEvent (keyUp) {
_root.alicemc.gotoAndStop(1);
}
it all works fine apart fom the hitTest, i am not very good with hitTest's and always get it wrong.
Can anyone see what i have done wrong?
the mc i am using for the hit has an instance name of "land".
Please help.
Ben.
-
flash mangler
try:
if (hitTest(_root.land)) {
etc.
}
Because the code is going on the _root.alice mc, the hitTest only needs to know what you are going to hit. In this case, _root.land
As ever with me, this may be incorrect, but this is how I remember doing it.
After checking the context help, it seems this is correct. fancy that
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|