I'm creating a simple flash game, where characters move on the groundwith some stages to jump over.

The problem is all the stages are acting as 1 object, which can make the character appear like it's flying in the air:

on air

All stages are called: ground3 Here is part of code where the character jumps and stay on the ground:

if(Hero.y_speed>0 && Hero.hitTestObject(ground3)){
    Hero.y_speed=0;
    if(space){
        trace("You clicked SPACE");
        Hero.y -= 80;
    }

Have you any ideas how to fix this?

有帮助吗?

解决方案

Use external libraries for your purposes, like this one.

Here is described, how to use it (you can find there also other useful informations).

import com.coreyoneil.collision.CollisionList;

var myCollisionList:CollisionList = new CollisionList(hero);

//add all stages separately
myCollisionList.addItem(stage[1...n]);

if(myCollisionList.checkCollisions().length > 0) {
     //colision detected
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top