I'm creating simple flash game. For now I'm coding character's control. I've added to character collisions with the ground & walls, but can't successfully add collisions with the ceiling, character jumping through the ceiling. Could you help me, please? Thank you.
Here is part of code, what I've tried:
if(space){
if(myCollisionsList.checkCollisions().length > 0) {
if (hitTestPoint(hero.x + 28, hero.y, true)){
/////////////////////////////////////////////////////////////////////////////////////
//here I need to add any code for character's collision with the ceiling.
/////////////////////////////////////////////////////////////////////////////////////
Hero.y_speed = 0; // this doesn't help me
}else{
Hero.y_speed = -jumpspeed;
}
I have created myCollisionsList where I keep all stages, walls for collisions with character. This method working for collisions when character is moving to right or left, because I just set character's x_speed to "0" when It touching the wall. But how can I stop It when touching the ceiling? Set character's y_speed to "0" doesn't help for me.
Image explains what's going on for now: