Saturday, 28 September 2013

How to reference a parent object (i.e; from root or stage)?

How to reference a parent object (i.e; from root or stage)?

I'm currently playing around with some AS3 platform gaming, and trying to
go with a cleaner object-based approach for platforms. In short, I'm
trying to detect if the player object is colliding with platform - ala:
if (!player.hitTestObject(this)) {
//player falls
}
However, the problem is in actually referencing the player object - the
player is at the following location (from the stage); manager.player -
wheras the platforms are at manager.level.foreground.
Is there any way to actually reference the player object from within the
foreground object as listed above, without passing in a constructor from
the player to each and every instance of the platform?

No comments:

Post a Comment