Be a Supporter!
Janj
Janj
  • Member since: Nov. 10, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
trace(hitTest) Jun. 11th, 2011 @ 01:31 PM Reply

http://www.newgrounds.com/dump/item/82a8 eba529779803af6c6ad5b904d663
I'm using AS2 & CS3.....................................
...^
Okay, I've tried to make a hitTest.................|
all the code is in the dumped file up there |
The trace function works perfectly, so I know it's hitTest. What's supposed to happen is that at loading, it traces 'testing' and then waits for the if. Then, if the 'luigi' mc is hitTesting the 'donkeykong' mc, it traces 'dk got run over'
But it doesn't trace!
Should I contact Adobe about this? It's really bugging me that all of the Flash version that I have on here don't work with something. And they both came from CD/DVDs.

Xeptic
Xeptic
  • Member since: May. 12, 2005
  • Offline.
Forum Stats
Member
Level 32
Game Developer
Response to trace(hitTest) Jun. 11th, 2011 @ 01:45 PM Reply

You're only hittesting once. What you want to do here is perform the hittest for every frame or mouse action.


BBS Signature
Janj
Janj
  • Member since: Nov. 10, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to trace(hitTest) Jun. 11th, 2011 @ 04:46 PM Reply

At 6/11/11 01:45 PM, Xeptic wrote: You're only hittesting once. What you want to do here is perform the hittest for every frame or mouse action.

What do you mean?

if(_root.luigi.hitTest(_root.donkeykong)){ 
	trace("dk got run over");
}

This checks if Luigi is hitTesting Donkey Kong.
But it won't check

Xeptic
Xeptic
  • Member since: May. 12, 2005
  • Offline.
Forum Stats
Member
Level 32
Game Developer
Response to trace(hitTest) Jun. 11th, 2011 @ 05:03 PM Reply

I mean it only checks this code once (when the code is loaded). If you want to make sure the hittest is checked continuously you need to place this code in an enter frame event.


BBS Signature
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to trace(hitTest) Jun. 12th, 2011 @ 09:45 AM Reply

simple fix, get rid of your current hittest code, open luigi's code, and insert this

onClipEvent(load){
Mouse.hide();
}
onClipEvent(enterFrame){
this._x+=(_root._xmouse - this._x)/3;
this._y+=(_root._ymouse - this._y)/3;
if(this.hitTest(_root.donkeykong._x,_root.donkeykong._y,true)){
	trace("im hitting donkey")
}
}

make sure to just replace the code.

Janj
Janj
  • Member since: Nov. 10, 2009
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to trace(hitTest) Jun. 12th, 2011 @ 02:51 PM Reply

At 6/12/11 09:45 AM, caseymacneil wrote: onClipEvent(load){
Mouse.hide();
}
onClipEvent(enterFrame){
this._x+=(_root._xmouse - this._x)/3;
this._y+=(_root._ymouse - this._y)/3;
if(this.hitTest(_root.donkeykong._x,_roo t.donkeykong._y,true)){
trace("im hitting donkey")
}
}

K, thanks! Hopefully I'll make use of this for my new game.