I'm very new in Android and game programming. I want to make a labyrinth game with the [Dijkstra algorithm].I want to create an AnimatedSprite that moved by DigitanOnScreenControl on TMX Map. But there's trouble, the AnimatedSprite still can go over the obstacles I made. So, How do I create a method for AnimatedSprite to run above the ITiledMap ?
this is the AnimatedSprite :
musuh = new AnimatedSprite(90, 90, this.mMusuhTextureRegion);
final PhysicsHandler physicsHandler2 = new PhysicsHandler(musuh);
musuh.registerUpdateHandler(physicsHandler2);
scene.attachChild(musuh);
this is the DigitalOnScreenControl :
this.mDigitalOnScreenControl = new DigitalOnScreenControl(0, CAMERA_HEIGHT - this.mOnScreenControlBaseTextureRegion.getHeight(), this.mBoundChaseCamera,
this.mOnScreenControlBaseTextureRegion, this.mOnScreenControlKnobTextureRegion, 0.1f, new IOnScreenControlListener() {
int TileNumber = 1;
@Override
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl,
final float pValueX, final float pValueY) {
physicsHandler2.setVelocity(pValueX * 100, pValueY * 100);
// Set the correct walking animation
if (pValueY == 1){
// Up
if (playerDirection != PlayerDirection.UP){
musuh.animate(ANIMATE_DURATION, 0, 2, false);
playerDirection = PlayerDirection.UP;
}
}else if (pValueY == -1){
// Down
if (playerDirection != PlayerDirection.DOWN){
musuh.animate(ANIMATE_DURATION, 9, 11, false);
playerDirection = PlayerDirection.DOWN;
}
}else if (pValueX == -1){
// Left
if (playerDirection != PlayerDirection.LEFT){
musuh.animate(ANIMATE_DURATION, 3, 5, false);
playerDirection = PlayerDirection.LEFT;
}
}else if (pValueX == 1){
// Right
if (playerDirection != PlayerDirection.RIGHT){
musuh.animate(ANIMATE_DURATION, 6, 8, false);
playerDirection = PlayerDirection.RIGHT;
}
}else{
if (musuh.isAnimationRunning()){
musuh.stopAnimation();
playerDirection = PlayerDirection.NONE;
}
}
}
});