开发者

how to do frame by frame animation in opengl

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);
    mfram开发者_开发百科eAnimation.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..


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜