Sea -> RE: Flash Q&A Thread 6 - We help! (12/22/2009 15:57:51)
|
@atriax quote:
If you don't want the character to go to the left, on the boundarie, add this: onClipEvent(enterFrame) { if(this.hitTest(_root.player)) { _root.player._x += 10; } } If you don't want the character to go to the right, just change the + symbol to -, like this: onClipEvent(enterFrame) { if(this.hitTest(_root.player)) { _root.player._x -= 10; } } Now, if you don't want the character to go up, add this: onClipEvent(enterFrame) { if(this.hitTest(_root.player)) { _root.player._y += 10; } } But if you don't want it to go down, just change the symbols: onClipEvent(enterFrame) { if(this.hitTest(_root.player)) { _root.player._y -= 10; } } Thanks Dudu (thats the borders) as for the animations: make it a mc (i assume it is) and make 3 frames inside it (double click) name the Idle frame "Idle" (without quotations) the right animation "R" and the left animation "L" (also U and D if you want, but if you don't have them then don't worry) this works for all Right, left, up, and down. onClipEvent(load){
speed=10;
}
onClipEvent(enterFrame){
a = "Idle";
if(Key.isDown(Key.RIGHT)){
_x+=speed;
a = "R";
}
if(Key.isDown(Key.LEFT)){
_x-=speed;
a = "L";
}
if(Key.isDown(Key.UP)){
_y-=speed;
a = "U";
}
if(Key.isDown(Key.DOWN)){
_y+=speed;
a = "D"
}
this.gotoAndPlay(a);
} put that on the character
|
|
|
|