Camera with "Fling" Effect

  ... the case you feel the need for a new feature or want to submit one.

Camera with "Fling" Effect

Postby thiago.oliveira » Fri May 25, 2012 2:25 pm

Hi everyone, this is my first topic in the forum.
In the first place: sorry for any english mistakes, I'm really bad at english. :?

Does anyone know of an existing camera on AndEngine GLES2 which does a scrolling animation that resembles a "fling"?

I want to do a scroll effect like the views on Android apps, that works like this: when you do a quick gesture and then release your finger, the view continues to scroll very fast and starts losing speed over time.

I think this effect will present a very nice experience for the game's users.

I found this topic with a discussion about this matter concerning GLES1, but the message was all mixed up with accelerometer tricks.

This isn't what I want, I'm talking about scrolling the camera with effects :)

Thanks in advance.
thiago.oliveira
 
Posts: 1
Joined: Mon May 21, 2012 3:37 pm

Re: Camera with "Fling" Effect

Postby jaym » Sun May 27, 2012 6:50 am

1. First of all, you should override the camera's onUpdate() method.
2. Create a boolean variable which will be present in the camera's onUpdate() method. True if the camera is scrolling, false otherwise.
3. If isScrolling == true, get the distance traveled between x amount of frames (this might have to be played with in order to find a nice effect).
4. The "fling" effect might look something like (in the onUpdate() method of the camera):
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if(distance > 0 && !isScrolling){
  2. mCamera.setCenter(this.getCenterX() + distance, this.getCenterY());
  3. distance -= pSecondsElapsed; // Multiply this if need be
  4. }
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


Let me know if you have trouble.
AndEngine for Android Game Development Cookbook - Based on AndEngine's latest, greatest, GLES2.0 AnchorCenter branch!
jaym
 
Posts: 690
Joined: Wed May 04, 2011 10:08 pm


Return to Features

Who is online

Users browsing this forum: No registered users and 5 guests