Forum Topic: Beat Em Up

(141 views • 6 replies)

This topic is 1 page long.

<< < > >>
Crying

Christicle

Reply To Post Reply & Quote

Posted at: 8/20/08 09:58 AM

Christicle EVIL LEVEL 10

Sign-Up: 05/11/08

Posts: 178

Okay, I've asked a similar question before, but I'm looking for a little help YET AGAIN....

_root.player.playerattack.hit has to hit _root.enemy

I've tried a bunch of stuff, but nothing worked. At the moment I have

onClipEvent(enterFrame) {
if(this.hitTest(_root.enemy._x, _root.enemy._y, true)) {
_root.enemyhealth -= Math.round(Math.random()*5);
}
}

Why won't this work? All the instance names are correct, and I've substituted the enemyhealth for a trace to test and the trace won't work either. Any ideas?


None

LonLonRanch

Reply To Post Reply & Quote

Posted at: 8/20/08 10:16 AM

LonLonRanch LIGHT LEVEL 17

Sign-Up: 05/22/05

Posts: 320

Well if the trace isn't working then there is clearly something wrong with the hitTest portion of your code. If your instances are all correct (double check and spell check) then make sure the paths are all correct.

If you are using _root.enemy then make sure the enemy is on the main timeline and not in any movieClips, if he is in a movieClip then you have to do _root.enemyMC.enemy

Also, what exactly are you having hitTest the enemy? with you're current code you realize that the movieClip must hit exactly where the enemy's _x and _y are, which means it can still pass through the enemy movieClip, but if it doesn't hit the right registration point it won't count as a hitTest


None

KynetiK-27

Reply To Post Reply & Quote

Posted at: 8/20/08 10:27 AM

KynetiK-27 NEUTRAL LEVEL 10

Sign-Up: 07/23/06

Posts: 740

onClipEvent(enterFrame) {
if(this.hitTest(_root.enemy)) {
_root.enemyhealth -= Math.round(Math.random()*5);
}
}

if that doesnt work your names are wrong


None

Christicle

Reply To Post Reply & Quote

Posted at: 8/20/08 10:27 AM

Christicle EVIL LEVEL 10

Sign-Up: 05/11/08

Posts: 178

Yeah, the instances are correct and the location of the MCs are correct, but maybe the hitTest registration is the problem.. I'm forgetting the hitTest code for a non-_x/_y hitTest. Would it be

if(this.hitTest(_root.enemy)) {

or

if(this.hitTest(_root.enemy, true)) { ?


None

Christicle

Reply To Post Reply & Quote

Posted at: 8/20/08 11:36 AM

Christicle EVIL LEVEL 10

Sign-Up: 05/11/08

Posts: 178


None

zrb

Reply To Post Reply & Quote

Posted at: 8/20/08 12:12 PM

zrb LIGHT LEVEL 11

Sign-Up: 08/08/06

Posts: 4,549

At 8/20/08 10:27 AM, Christicle wrote: if(this.hitTest(_root.enemy)) {

It would be that. Use the trace function to see if your codes actually work :

onClipEvent(enterFrame) {
if(this.hitTest(_root.enemy)) {
_root.enemyhealth -= Math.round(Math.random()*5);
trace("working");
}
}

School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

None

KynetiK-27

Reply To Post Reply & Quote

Posted at: 8/21/08 06:11 AM

KynetiK-27 NEUTRAL LEVEL 10

Sign-Up: 07/23/06

Posts: 740

At 8/20/08 10:27 AM, Christicle wrote: Yeah, the instances are correct and the location of the MCs are correct, but maybe the hitTest registration is the problem.. I'm forgetting the hitTest code for a non-_x/_y hitTest. Would it be

if(this.hitTest(_root.enemy)) {

or

if(this.hitTest(_root.enemy, true)) { ?

uhhh. did you even bother looking at what code i gave you?


All times are Eastern Standard Time (GMT -5) | Current Time: 06:36 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!