Be a Supporter!

As3- HitTest...

  • 123 Views
  • 2 Replies
New Topic Respond to this Topic
bitcubes
bitcubes
  • Member since: Nov. 29, 2013
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
As3- HitTest... 2014-02-16 16:32:56 Reply

so I've recently left as2 and tried to learn some as3 but I'm having a problem with hitTest
I have literally searched for hours on a way to fix this on google but none seem to work because I have to use (this. because there are multiple copies of one obstacle, and i put the code inside of that obstacle

in as2 it would normally be like this..

if(this.hitTest(_root.player)
{
 _root.gotoAndPlay("fail");
}

this is what I tried in as3 but it doesnt work
it shows no error but the code just does nothing.

if (trash.hitTestObject(MovieClip(root).player))
{
	MovieClip(root).gotoAndPlay("fail");
}

how can I write

if(this.hitTest(_root.player)
{
 _root.gotoAndPlay("fail");
}

in as3 version

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to As3- HitTest... 2014-02-16 16:51:32 Reply

At 2/16/14 04:32 PM, bitcubes wrote: how can I write

if(this.hitTest(_root.player)
{
_root.gotoAndPlay("fail");
}

in as3 version

This belongs in flash forum where stuff like this gets asked every day. Since you've switched to as3, I'm gonna suggest you also switch to never using root. Quick search finds this thread to help, and there are literally a hundred other ones you can look for.

bitcubes
bitcubes
  • Member since: Nov. 29, 2013
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to As3- HitTest... 2014-02-16 17:16:09 Reply

all I got from that link is that root should not be used, but that really does not help me much because root is not the problem, hitTest is the problem,and I cant switch back to as2 because I'm using flash cc and theres no as2 in that, ill try posting on the flash section