hittest help

8 posts

Flag Post

i type in this code and it dousent do any thing

onClipEvent (enterFrame) {
if (root.hero, hitTest(root.wall)) {
gotoAndPlay (2);
}
}

any help here

 
Flag Post

onClipEvent (enterFrame) { if (root.hero.hitTest(root.wall)) { gotoAndPlay(2); } }

The reason there is a dot between the hero and the hitTest() function is because hero is a MovieClip. hitTest() is a MovieClip method (a function associated with MovieClips), and the correct method notation for an instance method (one that is applied to one individual MovieClip as opposed to the MovieClip class in general) is instanceName.function(), in this case root.hero.hitTest(root.wall)

 
Flag Post

What’s with the comma XD

 
Flag Post

ok what are you trying to do? where is the code located? and for goto and play do you want the scene to play or a movie clip?

 
Flag Post

i want the scean to play

 
Flag Post

If you want it to go to a different scene, you have to pass two parameters to gotoAndPlay.

gotoAndPlay( scene , frame )

Where scene is a string that contains the name of the scene you want to play.

 
Flag Post
onClipEvent (enterFrame) {
	if (_root.hero.hitTest(_root.wall)) {
		_root.gotoAndPlay(2);
	}
}

and go and stick this in hero…and make sure…that the wall’s instance name is “wall” same with hero. im not sure if it will work but as far as i know it will

 
Flag Post

Put this in the frame so it’s easier lolz. And for “?”, which is I have no idea what “variable” or scene you wanted, just replace it what you want.

onEnterFrame = function() {
if (_root.hero.hitTest(_root.wall))
_root.?.gotoAndPlay(2);
}
}

I’m lazy to put it in Flash lolz.