-
Help again...
i tried to make my "man" stop when he hits something but it won't work...
here my code
onClipEvent (load) {
if(_root.man.hitTest ((this){
stop();
}
}
help please
-
-
i guess noneone whats to help mme
-
the problem is that your question is too vague, from the looks of the code you posted it doesnt work becasue 'this' has no obvious meaning.. what is 'this' what piece of material does it equate to in the movie, is 'this' a wall, another object...
there are aot of hit detection tutorials here on flash kit and in the flash help files. tool arround in there and i think you may find what you are looking for.
-
-
onClipEvent (enterFrame) {
if (this.hitTest(_root.man)) {
stop();
}
}
Assuming there is a timeline playing inside _root.wall. This is what the 'stop()' action will do, stop the playhead running inside _root.wall. If you meant for something else to happen, you should explain.
gparis
-
Originally Posted by 3vobob
i tried to make my "man" stop when he hits something but it won't work
Ok i just saw that. Post the code that make the "man" walk.
gparis
-
k here the code to make the man walk
Code:
onClipEvent (load){movespeed = 0;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
play();
_rotation = 90;
_x+= movespeed;
}
if (Key.isDown(Key.LEFT)) {
play();
_rotation = 270;
_x-= movespeed;
}
if (Key.isDown(Key.UP)) {
play();
_rotation = 0;
_y-= movespeed;
}
if (Key.isDown(Key.DOWN)) {
play();
_rotation = 180;
_y+= movespeed;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
_rotation = 45;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
_rotation = 315;
}
if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
_rotation = 135;
}
if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
_rotation = 225;
}
}
-
with the variable movespeed = 0, i doubt the object moves. So when the hitTest happens, just set that var to 0.
gparis
-
the background moves it's like in stick rpg... my character satys in the middle while the background moves
-
so you want what to happen when man hits wall? the background stops moving? or the man animation stops playing?
Also, where is that wall? is it in the background movieclip?
gparis
-
ya it's in the background movieclip and ya thats the effect i want the background to stop playing... and than we i get way from the wall the animation keeps on playing...
-
So post the code of the moving background, because it's that code that'll need to be altered.
gparis
-
k here the code fot the background...
Code:
onClipEvent (load) {
movespeed = 6;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x-= movespeed;
}
if (Key.isDown(Key.LEFT)) {
_x+= movespeed;
}
if (Key.isDown(Key.UP)) {
_y+= movespeed;
}
if (Key.isDown(Key.DOWN)) {
_y-= movespeed;
}
}
-
on the wall:
onClipEvent (enterFrame) {
if (this.hitTest(_root.man)) {
_parent.movespeed=0;
} else {
_parent.movespeed=6;
}
}
gparis
-
hey dude that didn't work... i tried changing stuff but still won't work... i think it's because you ment the parent (man) speed quale to 6... anywya it won't work... well he goes to the wall and stops when he hits it but after that he won't move
-
The _parent of wall is, from what i understood, the background.
gparis
-
?? if you want me to show you want it does pm me
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
|