Reputation:
I'm developing for Android and am a little confused about what is the best way to write 2d full-screen games. On my desktop PC version of my game I create a class which extends the Canvas class and go from there, overloading the update() method to draw to the screen. My intention is to port it to Android.
However I've noticed some online tutorials don't use Canvas, and use View instead. I'm used to using Canvas and drawing with Graphics objects using drawImage(), for example.
Is there a best (i.e. fastest, most accepted) choice out of the two (Canvas or View) or doesn't it matter. Perhaps one extends the other anyway?
Upvotes: 2
Views: 222
Reputation: 1177
A view is your base widget, think of it sort of like a blank panel to which other widgets can be added, or with which you can implement your own widgets. A view has a draw method you can override which takes a canvas as a parameter. You do your rendering in that method. The draw operators you are looking for should be available from the Paint class, which draws to a Canvas.
Upvotes: 2