Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple Collision Detection in ActionScript 2?

New Here ,
Nov 03, 2012 Nov 03, 2012

I am trying to make a simple maze game, but the collision detection is not working. I have the player moving with the arrow keys, and I am trying to make it so that when the player collides with the wall, it goes to a certain frame. I have this code in the wall movie clip:

onClipEvent (enterFrame) {

if (_root.player.hitTest(this))

{

gotoAndStop("death");

}

}

The player's instance name is "player" and the wall's instance name is "walls1". When the player hits the wall, the player just goes right through it. I'm pretty sure it's something with the collision, not the "gotoAndStop("death");" because I tested it with "gotoAndStop(5);" and the player still goes through the wall.

If someone could help me, I would really appreciate it. Thanks in advance!

TOPICS
ActionScript
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 03, 2012 Nov 03, 2012

What object are you expecting to goto frame 5 ("death")?

You should move your code to the main timeline and target the objects.

Translate
LEGEND ,
Nov 03, 2012 Nov 03, 2012

What object are you expecting to goto frame 5 ("death")?

You should move your code to the main timeline and target the objects.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 03, 2012 Nov 03, 2012

Thank you so much! The problem was it was trying to go to frame 5 in the object, not the timeline.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 03, 2012 Nov 03, 2012
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines