[android-developers] Re: Sprite imaging for 2D game programming
Take a look at the Canvas method drawBitmap() http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.Rect,%20android.graphics.Paint) with that one you can specify the bitmap (the sprite sheet), the subset of the bitmap you want to display (the current frame) and the destination on the screen. To make it animate you'll want to keep track of the amount of time you've displayed the current frame, you can do this by updating a counter by the amount of time that passes between each update call e.g. when you update model position etc. When it exceeds whatever you've decided to be your frame-rate you change the current frame and reset the timer. I'll see if I can make some of my code a little more readable and post it up later if you're still stuck. On May 17, 4:23 pm, g1port.com gmt...@gmail.com wrote: Hi guys, For a 2D game programming, I'm trying to learn about loading an image file for all states of a game character (simply a walking soldier lets say) and simply animate it. I think this classic method is called as sprite imaging that you load whole image of all states of the character that you want to animate. Is there anyone that can provide some sample code about this or at least can you tell me which classes to use, how to refer some 'part of' whole image file and animate it etc. Your help is much appreciated. Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Sprite imaging for 2D game programming
That's great guys, thanks a lot! On May 18, 9:09 am, MrChaz mrchazmob...@googlemail.com wrote: Take a look at the Canvas method drawBitmap() http://developer.android.com/reference/android/graphics/Canvas.html#d...) with that one you can specify the bitmap (the sprite sheet), the subset of the bitmap you want to display (the current frame) and the destination on the screen. To make it animate you'll want to keep track of the amount of time you've displayed the current frame, you can do this by updating a counter by the amount of time that passes between each update call e.g. when you update model position etc. When it exceeds whatever you've decided to be your frame-rate you change the current frame and reset the timer. I'll see if I can make some of my code a little more readable and post it up later if you're still stuck. On May 17, 4:23 pm, g1port.com gmt...@gmail.com wrote: Hi guys, For a 2D game programming, I'm trying to learn about loading an image file for all states of a game character (simply a walking soldier lets say) and simply animate it. I think this classic method is called as sprite imaging that you load whole image of all states of the character that you want to animate. Is there anyone that can provide some sample code about this or at least can you tell me which classes to use, how to refer some 'part of' whole image file and animate it etc. Your help is much appreciated. Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Sprite imaging for 2D game programming
I basically used one bitmap, and a call to canvas after a specified amount of time using a different drawing rectangle, and some canvas transformations On May 18, 4:18 am, Genc gmt...@gmail.com wrote: That's great guys, thanks a lot! On May 18, 9:09 am, MrChaz mrchazmob...@googlemail.com wrote: Take a look at the Canvas method drawBitmap() http://developer.android.com/reference/android/graphics/Canvas.html#d...) with that one you can specify the bitmap (the sprite sheet), the subset of the bitmap you want to display (the current frame) and the destination on the screen. To make it animate you'll want to keep track of the amount of time you've displayed the current frame, you can do this by updating a counter by the amount of time that passes between each update call e.g. when you update model position etc. When it exceeds whatever you've decided to be your frame-rate you change the current frame and reset the timer. I'll see if I can make some of my code a little more readable and post it up later if you're still stuck. On May 17, 4:23 pm, g1port.com gmt...@gmail.com wrote: Hi guys, For a 2D game programming, I'm trying to learn about loading an image file for all states of a game character (simply a walking soldier lets say) and simply animate it. I think this classic method is called as sprite imaging that you load whole image of all states of the character that you want to animate. Is there anyone that can provide some sample code about this or at least can you tell me which classes to use, how to refer some 'part of' whole image file and animate it etc. Your help is much appreciated. Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Sprite imaging for 2D game programming
take a look at this reference http://developer.android.com/guide/topics/resources/available-resources.html and take a look through some of the tutorials here http://www.anddev.org/ On May 17, 10:23 am, g1port.com gmt...@gmail.com wrote: Hi guys, For a 2D game programming, I'm trying to learn about loading an image file for all states of a game character (simply a walking soldier lets say) and simply animate it. I think this classic method is called as sprite imaging that you load whole image of all states of the character that you want to animate. Is there anyone that can provide some sample code about this or at least can you tell me which classes to use, how to refer some 'part of' whole image file and animate it etc. Your help is much appreciated. Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---