Reputation: 2494
Can anyone guide me for animation in opengl. I have tried using normal frame by frame animation and using canvas but i have some drawbacks as i need to merge two bitmap as single bitmap and make animation so now i trying to attempt to use opengl. I have tried this code
img.setOnClickListener(this);
int reasonableDuration = 50;
mframeAnimation = new AnimationDrawable();
mframeAnimation.setOneShot(false);
mframeAnimation.addFrame(frame1, reasonableDuration);
mframeAnimation.addFrame(frame2, reasonableDuration);
mframeAnimation.addFrame(frame3, reasonableDuration);
mframeAnimation.addFrame(frame4, reasonableDuration);
mframeAnimation.addFrame(frame5, reasonableDuration);
mframeAnimation.addFrame(frame6, reasonableDuration);
mframeAnimation.addFrame(frame7, reasonableDuration);
moveLefttoRight = new TranslateAnimation(400, 0, 0, 0);
moveLefttoRight.setDuration(3000);
moveLefttoRight.setFillAfter(true);
img.setBackgroundDrawable(mframeAnimation);
mframeAnimation.setVisible(true, true);
//If this line is inside onClick(...) method of a button, animation works!!
}
after googled i got a above code normal frame by frame animation but here i need to stop animation at certain point so i need to go for opengl. Please guide me..
Upvotes: 0
Views: 1813
Reputation: 162164
Your mistake lies in mixing event handling with animation iteration. Usually you have some display function that gets called in a loop. Prior to each display iteration you advance the animation state and have the display function render the scene in the current state.
The event handlers OTOH just trigger animations, but don't animate them.
Upvotes: 1
Reputation: 16720
I been reading about that lately and what i can do for you is forward to this links:
http://obviam.net/index.php/a-very-basic-the-game-loop-for-android/
http://www.rbgrn.net/content/54-getting-started-android-game-development
Not sure if that is what you are looking for but hope it helps
Upvotes: 1