smart-fun / smartGL

SmartGL is a Graphic Engine for creating Android Games and Apps. It is based on OpenGL and handles 2D Sprites and 3D Textured Objects.
Apache License 2.0
109 stars 24 forks source link

Need help in changing frames from a sprite sheet drawable? #8

Closed gauravchandra19 closed 7 years ago

gauravchandra19 commented 7 years ago

Hey, I am new to using and learning about sprites and your library seemed pretty simple to use and I have got the basic code working that you gave on the main screen. Now I want to change frames from a sprite sheet with a character but I am not able to follow how to do that. Can you help me with simple code for sprite animation? Thanks in advance.

smart-fun commented 7 years ago

Hello and thank you for using smartGL !

I think that all you need is described in the wiki here: https://github.com/smart-fun/smartGL/wiki

look at the "Animated Sprite Textures" section :)

Arnaud.

gauravchandra19 commented 7 years ago

Hey, as written there I created a bitmap and added its width and height and added the frames in another class as below: Bitmap explosionSprite= BitmapFactory.decodeResource(getResources(),R.drawable.sprite_example); mAnimatedSprite=new AnimatedSprite(explosionSprite.getWidth(),explosionSprite.getHeight()); mSpriteTexture=new Texture(MainActivity.this,R.drawable.sprite_example); mSprite=new Sprite(120,120); mSprite.setTexture(mSpriteTexture); renderPassSprite.addSprite(mAnimatedSprite); Here is the image I am using for sprite animation: sprite_example

smart-fun commented 7 years ago

Nice! Is all working as expected?