Need Help with FlashPunk Collision Detection


(Selena Thomas) #1

Hi there,

I am relatively new to using FlashPunk and I am currently facing an issue with collision detection in my game. I have read through the documention and tried implementing the collision checks but I am still facing the issue.

Particularly, I have entities (its been a player and a enemy) and I want to detect collisions between them accurately. I have set up my entities using Entity and EntityList. I am using Hitbox for collision detection. I am mentioning version of my code structure:

public class Player extends Entity {
public function Player(x:Number, y:Number) {
    super(x, y, new Hitbox(32, 32));
}

override public function update():void {
    // Player movement logic here
}

}

public class Enemy extends Entity { public function Enemy(x:Number, y:Number) { super(x, y, new Hitbox(32, 32)); }

override public function update():void {
    // Enemy movement logic here
}

}

Is there anyone who can guide me on how to implement collision detection between these entities in right way ? Should I use collideWith or another method ? Any code examples or tips would be really helpful. I also went through this thread:http://developers.useflashpunk.net/t/collision-detection-kit-with-flashpunk-cissp/ but couldn’t get the solution.

Thanks a lot for your assistance.

Selena