Be a Supporter!

Hit Test does not work...

  • 281 Views
  • 10 Replies
New Topic Respond to this Topic
Gesh
Gesh
  • Member since: Sep. 8, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Hit Test does not work... 2009-03-20 12:54:44 Reply

Ive copyed 2 types of codes for hit test that work on the tutorial example but when i put the same code in my own game the object just goes over/under the wall...

can any1 help me with this?

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Hit Test does not work... 2009-03-20 13:24:02 Reply

Need more info if you want help. Like, the code, the instance names, which version of actionscript, etc


- - Flash - Music - Images - -

BBS Signature
Gesh
Gesh
  • Member since: Sep. 8, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Hit Test does not work... 2009-03-20 13:30:20 Reply

At 3/20/09 01:24 PM, Denvish wrote: Need more info if you want help. Like, the code, the instance names, which version of actionscript, etc

onClipEvent(enterFrame) {
if(_root.char.hitTest(_root.wall1)) {
this._y -=10;
}
}

This is the code the mc that can move's name is char and the barriar is wall1 so basicely when it hits the barriar it has to stop but it just move's trough it

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Hit Test does not work... 2009-03-20 13:35:00 Reply

first off... dont copy code, learn code... secondly, try this: and tell us what happens

onClipEvent(enterFrame) {
if(this.hitTest(_root.wall1)) {
trace ("you have hit the wall");
}
}


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Gesh
Gesh
  • Member since: Sep. 8, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Hit Test does not work... 2009-03-20 13:42:09 Reply

At 3/20/09 01:35 PM, Yambanshee wrote: first off... dont copy code, learn code... secondly, try this: and tell us what happens

onClipEvent(enterFrame) {
if(this.hitTest(_root.wall1)) {
trace ("you have hit the wall");
}
}

when i copy it a few times i learn it ...as for this code u gave me the same thing happens no hit ditection

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Hit Test does not work... 2009-03-20 13:45:08 Reply

At 3/20/09 01:42 PM, Gesh wrote: when i copy it a few times i learn it ...as for this code u gave me the same thing happens no hit ditection

ok, the problem is then definitly hte fact that its not hitting correct, are you sure your instance names are all correct (caps sensitive). And remember instant names, not symbol names


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Gesh
Gesh
  • Member since: Sep. 8, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Hit Test does not work... 2009-03-20 13:48:16 Reply

At 3/20/09 01:45 PM, Yambanshee wrote:
At 3/20/09 01:42 PM, Gesh wrote: when i copy it a few times i learn it ...as for this code u gave me the same thing happens no hit ditection
ok, the problem is then definitly hte fact that its not hitting correct, are you sure your instance names are all correct (caps sensitive). And remember instant names, not symbol names

I think we are getting to the problem...whats the diffarence betwean instance and symbol names ?

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Hit Test does not work... 2009-03-20 14:00:11 Reply

problem identifiyd!

im guessing you know what a symbol name is (the name its given when you make it). When you add it to the stage, and click on it with the properties panel open (bttom of screen), at the far left top, you should see a drop down with (probably) the word movie clip on it. Right underneith that is a input box. THAT'S the instance name.


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Gesh
Gesh
  • Member since: Sep. 8, 2008
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to Hit Test does not work... 2009-03-20 14:07:45 Reply

At 3/20/09 02:00 PM, Yambanshee wrote: problem identifiyd!

im guessing you know what a symbol name is (the name its given when you make it). When you add it to the stage, and click on it with the properties panel open (bttom of screen), at the far left top, you should see a drop down with (probably) the word movie clip on it. Right underneith that is a input box. THAT'S the instance name.

Thanks alot banshee :D now i can put my epic idea into making :D TYVM!!!Ohh im so happy right now i think im gona go kill the cookie :D

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Hit Test does not work... 2009-03-20 14:08:34 Reply

Ohh im so happy right now i think im gona go kill the cookie :D

no prob, pm me if u need more help


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
fjgamer
fjgamer
  • Member since: Aug. 15, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Hit Test does not work... 2009-03-20 16:03:50 Reply

This *must* be this guy's first attempt at coding anything in Flash.
Instance names have been necessary since, well, ever.
AS1 or AS2?