PDA

View Full Version : hitTesting mcs inside mcs



leonthelion
January 4th, 2008, 04:55 AM
How can you do that? I have an mc and inside the first frame of that I have another mc, which contains the circles attacks. I'm really bad at explaining this so heres my file D: Thanks

So heres what im doing:
1.check if the mc inside the first mc(in the main timeline) hits the second mc (in the main timeline)
2.if it is reduce hp variable or whatever
3.well thats it :D
Thanks
if this isn't clear just say and I'll try to explain it better :D

hatu
January 4th, 2008, 07:38 AM
That code is pretty terrible :ogre:

You should try atleast putting everything in one frame.

To access a mc inside a mc you can just use mc1.mc2 to refer to it. mc2 here is inside mc1.

so if there's a movieclip called mc2 inside mc1 then use
mc1.mc2._x = 100;
to change it's _x for example

leonthelion
January 4th, 2008, 03:52 PM
That code is pretty terrible :ogre:

You should try atleast putting everything in one frame.

To access a mc inside a mc you can just use mc1.mc2 to refer to it. mc2 here is inside mc1.

so if there's a movieclip called mc2 inside mc1 then use
mc1.mc2._x = 100;
to change it's _x for example
Whats bad about the code and how could I put it in one frame? Anyway do you mean put something like: instancename.whatever or do you mean something else? Thanks

Lou
January 4th, 2008, 04:39 PM
if "sword" is a movieclip inside of "player", and "enemy" is a separate movieclip on the stage:

ActionScript Code:

if (enemy.hitTest(player.sword)){
//action
}

leonthelion
January 4th, 2008, 04:49 PM
if "sword" is a movieclip inside of "player", and "enemy" is a separate movieclip on the stage:

ActionScript Code:


if (enemy.hitTest(player.sword)){


//action
}

I can't get it to work :( I did this on the enemy:

onClipEvent(enterFrame){
if (enemy.hitTest(circle.attack)){
this.gotoAndStop(2)
}}
&


onClipEvent(enterFrame){
if (this.hitTest(circle.attack)){
this.gotoAndStop(2)
}}
&


onEnterFrame=function(){
if (enemy.hitTest(circle.attack)){
this.gotoAndStop(2)
}}

Anyone see whats wrong with it? Tell me if you want me to post the new file. Thanks :D

Lou
January 5th, 2008, 12:18 AM
scope _root.

onEnterFrame=function(){
if (_root.enemy.hitTest(_root.circle.attack)){
this.gotoAndStop(2)
}}

leonthelion
January 5th, 2008, 01:24 AM
I got it :D


enemy.onEnterFrame=function(){
if (this.hitTest(circle.attack)){
this.gotoAndStop(2)
}}

Thanks ^^