Reputation: 14891
I am thinking of doing a platform game in flash. The approach towards level design I am thinking of is to have each level as an image with either a transparent or solid colour background.
Using regular hittest functions determines if one object has touched another object. In this case this will always return true.
My question is, I want a hitTest function to return true if the player character collides with any non transparent / solid colour on the level.
If I do have a transparent background I will probably have another image as a background that would move a little more than the level image to create a simple parallax effect. If I do this, the hitTest function would need to ignore the background image (I don't think this will be an issue, but still better to specify and be called an idiot than not).
Upvotes: 0
Views: 652
Reputation: 80
This is an inefficiency method but its the simplest solution:
if (player.hitTestObject(platform) && platform.alpha == 1) {
trace("we landed!!!");
} else {
trace("we fell!!!");
}
Upvotes: 2
Reputation: 8121
Consider using the AS3 Collision Detection Kit as it can detect hits on colours.
Upvotes: 1