Elf2008
03-08-2008, 04:28 PM
Hi...
I am working on a Flash RPG. I know it will take me a while to complete it but hopefully one day i will have it finished.
I am having trouble getting a collision code to work. What i want is, when my man MovieClip collides with the wall MovieClip, i want him to stop. At the moment i have it so when you touch the wall it stopes, which is what i want, but then i cant move away. I have got the code so u can control the MovieClip with the arrow keys.
Here is my code:
onClipEvent (load) {
power = 10
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)){
_x -= power;
}
if (Key.isDown(Key.RIGHT)) {
_x += power;
}
if (Key.isDown(Key.UP)) {
_y -= power;
}
if (Key.isDown(Key.DOWN)) {
_y += power;
}
}
onClipEvent (enterFrame) {
if (_root["wall"].hitTest(_root["man"])){
var power = 0;
}
}
When my Man collides with the wall he stops, but then i cant move away from the wall.
Please can someone tell me some code that will let me collide and stop at the wall, and let me move away after. And then when i collide for a second time he stops, and can move away again and so on.
Thank You
Elf
I am working on a Flash RPG. I know it will take me a while to complete it but hopefully one day i will have it finished.
I am having trouble getting a collision code to work. What i want is, when my man MovieClip collides with the wall MovieClip, i want him to stop. At the moment i have it so when you touch the wall it stopes, which is what i want, but then i cant move away. I have got the code so u can control the MovieClip with the arrow keys.
Here is my code:
onClipEvent (load) {
power = 10
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)){
_x -= power;
}
if (Key.isDown(Key.RIGHT)) {
_x += power;
}
if (Key.isDown(Key.UP)) {
_y -= power;
}
if (Key.isDown(Key.DOWN)) {
_y += power;
}
}
onClipEvent (enterFrame) {
if (_root["wall"].hitTest(_root["man"])){
var power = 0;
}
}
When my Man collides with the wall he stops, but then i cant move away from the wall.
Please can someone tell me some code that will let me collide and stop at the wall, and let me move away after. And then when i collide for a second time he stops, and can move away again and so on.
Thank You
Elf