4

Currently I am developing a game using andengine. In my game I have to bring trial effect which follows finger like fruit ninja. I have tried Rendering with BaseGameActivity and LayoutGameActivity with xml file.

But while combining opengl Rendering with andengine RendererSurfaceView it shows some delay as well as sprite in RendererSurfaceView doesn't listen to the onAreaTouched().

I am in confusion. could you please help in what manner I have to bring Trial Effect like Fruit Ninja in my game?

Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
stackuser
  • 239
  • 2
  • 7

2 Answers2

1

Well, I'm not sure if I totally understand, but I may be able to start you off...

In your BaseGameActivity's onCreateScene method, after you create your scene, set a touch listener. In your listener check if it's a move event, so you can get the x and y coordinates.

    scene.setOnSceneTouchListener(new IOnSceneTouchListener() {
        @Override
        public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
            if (pSceneTouchEvent.isActionMove()) {
                Log.d(App.LOG_TAG, "x: " + pSceneTouchEvent.getX() + " y: " + pSceneTouchEvent.getY());
                return true;
            }
            return false;
        }
    });

You'll need to keep track of the coordinates and probably do a smoothing algorithm on them, then draw some graphic over that path.

devnate
  • 744
  • 5
  • 8
0

I created something similar a while ago [wasn't intended but somehow I made it] but I kind of lost the code so I'll just explain the process to you

To create a trial effect all what you have to do is use particle systems and attach it on touch , move it with the finger [change it's location when isActionMove()] and detach [or have it fade out first so you get nice effect] it on isActionUp()

I used this process to create a flame effect that follows your finger, the rest is up to you and how you mess around with the particle emitter to make the particles appear as a slash

Jimmar
  • 4,194
  • 2
  • 28
  • 43