1

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;
                     }
             }
            }
        });
Noviwidi
  • 11
  • 3
  • 1
    what is your code? what did you try? edit your question plz. – DRPK Nov 09 '17 at 05:01
  • kindly check this before posting a question https://stackoverflow.com/help/how-to-ask – Navneet Krishna Nov 09 '17 at 05:03
  • @DRPK the question edited. So do you know how to create a method for AnimatedSprite to run above the ITiledMap. I really don't know about it, and I looked for that method but it doesn't exist. Hope you can help me. (Sorry for my bad english) ^^ – Noviwidi Nov 14 '17 at 22:29
  • @NavneetKrishna ok thankyou ^^ – Noviwidi Nov 14 '17 at 22:32

0 Answers0