ForumsProgramming Forum[Need help] hittest only works once?

60 13509
Voidcrystal
offline
Voidcrystal
138 posts
Nomad

when i make thise script:

onEnterFrame = function(){
if(ss.hitTest(_root.c2)){
_root.ss._x = -49.4;
}
}

it only does go to cords -49.4 once! the next time it happens nothing, can you solve it abn :P? Or anyone else??

  • 60 Replies
Voidcrystal
offline
Voidcrystal
138 posts
Nomad

ss is the whole movie clip

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

This is maybe something,

function onEnterFrame(){
while(ss.hitTest(_root.wall)){
ss._x = -300;
}
}

But when i hit it the second time it lags up and then it pops up a sign that says: a script is running slowly, want to abort it? [yes] [no]

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

That's seems like it might be because you are running lots of hitTests inside the movieclip, maybe you are making more than 1 or something...

I just thought of something, are you doing the same hitTest inside the movieClip and somehow cancelling out the first one or something?

Could I see the swf?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

I am not running any more Hittest :S

here is the mc's frame:

tr();

function tr() {
speed = 0.5
muv = 0
gravity = 0
}

function onEnterFrame() {

if (Key.isDown(Key.RIGHT) or Key.isDown(68)) {
muv += speed;
}
if (Key.isDown(Key.LEFT) or Key.isDown(65)) {
muv -=speed;
}




mc._x += muv;
mc._y += gravity;

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

well?

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Could you upload the swf to swfcabin or somethin? It might help me figure out what's wrong.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

i can send you the .fla :P

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

http://www.swfcabin.com/open/1264627698 there is the swf, no fla needed

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

well?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

weeell :P?

plasmafish
offline
plasmafish
252 posts
Nomad

It took you that long to do that?

plasmafish
offline
plasmafish
252 posts
Nomad

I'm just saying that hittest would work for you but you needed to post your .FLA or else there is no point in anyone trying to help. You are giving a piece of your code instead of the whole thing.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

where should i upload the swf ?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

i mean fla but i have found the problem, but i don't know how to fix it.

The problem is that the script for moving the char is in a movie clip frame and the collision in a normal frame, but i can't take the script out of the movieclips frame because that makes it go ****** :P but how to make a script to react on the frame in the movie clip?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

how to control a movie clip inside a movie clip on the first frame :P?

Showing 16-30 of 60