I'm creating simple flash game. I've added collisions for character with walls, stages, etc. But as I see for now collisions are with all objects which I add to stage. When I add background - character can't move (because is collision with background). How to avoid It?
Here is myCollisionList with character (Hero):
var myCollisionList:CollisionList = new CollisionList(Hero);
myCollisionList.addItem(stage1);
myCollisionList.addItem(stage2);
myCollisionList.addItem(stage3);
Here is part of code for moving character to left side. When added background I always get trace("Touching wall!"). How to avoid It?
if(left){
Hero.x_speed = -walkspeed;
setDirection(1);
if(myCollisionList.checkCollisions().length > 0) { // checking if is anything in collision list
// I think here is problem, but don't know how to fix It?
if (hitTestPoint(char.x - 26, char.y+20, true)){ //checking if character touching any object (have collision with anything)
trace("Touching wall!");
Hero.x_speed = 0;
}
else {
Hero.x_speed = 8;
}}
I've tried to use HitTestObject too (but if possible I need to use HitTestPoint)
if (Hero.HitTestObject(stage1 || stage2 || stage3)){
.....
}
But It works only with first stage1, for other 2 doesn't work.