SBA
SBA

Reputation: 31

Collision Detection hitTestObject not working.. ish

Obviously as you can see from this clip below, the Hit and Miss is not corresponding to the actual event on the stage. why? It works only if I give the objects instance name, but not working when using the var name. why?

here's the code:

import flash.events.Event;
var gball: SmallGreenBall1_T = new SmallGreenBall1_T();
var bucket: allBuckets = new allBuckets();
this.addEventListener(Event.ENTER_FRAME, handleCollision)
function handleCollision(evt: Event): void {
  if (gball.hitTestObject(bucket)) {
  output_txt.text = "HIT"
  } else {
  output_txt.text = "MISS"
  }
}

https://www.youtube.com/watch?v=rL4N5Abokf0[Hit and Miss is not corresponding to the actual event on the stage][1]

Upvotes: 1

Views: 29

Answers (1)

SBA
SBA

Reputation: 31

Problem solved. Rookie mistake, I needed to addChild the object not preposition them on stage.

Upvotes: 1

Related Questions