Here is the correct link: http://www.droidnova.com/playing-with-graphics-in-android-part-i,147.html
On Jul 15, 2:33 pm, ayanir <[email protected]> wrote: > Hello Dianne , > > Thank you for you response. > according to your words, I do not need that each Box will be as a > Surface view but only one game surface view and the only way I can > mange the game objects(Boxes etc.) is by using a "low level" > management of drawing and event handling. > If I trying to answer my own question then option (4) is the way to do > it. > I thought I will design my game "Flash style" where each object draw > itself and the main Activity will handle the events and drawing > Threads but I presume we are not there yet. > > It helped me a lot to read "Playing with graphics in Android > Tutorial" (http://www.droidnova.com/playing-with-graphics-in-android- > part-i,147.html) which spread a light on hot to use surface view and > animation. > > Regards to you all > ayanir > > On Jul 14, 7:06 pm, Dianne Hackborn <[email protected]> wrote: > > > I very strongly recommend that you don't use multiple surface views. A > > surface view is a very heavy-weight object, and intended for the primary > > area of the window -- for example, the video part of a video player, the > > playfield of a game, etc. It is basically an overlay, and actually its own > > separate full window that is simply being Z-ordered with your main window to > > make it look like they are related. > > > I don't know what your "complicated" animation sequence is, but just having > > some animation is not enough reason to use a surface view. Worst case, you > > can just create an off-screen bitmap that you draw the animation in and > > update the screen by drawing that bitmap to the screen with the normal > > invalidate() mechanism. If you need the performance of a surface view, then > > you should design your game so that your entire playfield is on surface > > view, and you take care of drawing each of your boxes inside of that and > > manage them however you want (not as their own views). > > > On Tue, Jul 14, 2009 at 4:27 AM, ayanir <[email protected]> wrote: > > > > Hello, > > > > I'm a new Android developer. > > > I would like to make a simple game using the SurfaceView (Canvas > > > drawing). > > > > the game has a a custom Object name Box. Box can draw itself and need > > > to get an event when it is clicked. when it does, there is an > > > animation sequence coming out of the box like a "jumping clown". > > > I have several Boxes on the screen when each of them can be activated. > > > Several Boxes animation can also be presented simultaneously. > > > > Here it gets tricky: > > > Since I have a "complicated" animation sequence, each Box extends > > > SurfaceView. > > > The problem is I haven't figured it out how can I handle several > > > SurfaceView's drawing using only one Thread (in order to present an > > > animation I need to use one) and also how can I get the onClick/ > > > onThouch event from my Activity to each of my Boxes. > > > > The LunarLanding example in the SDK uses only one Thread but also uses > > > only one SurfaceView which manage the animation of the game components > > > (there are no several game components SurfaceViews). Also, there is no > > > need to get onTouch event, so this example doesn't match to my case. > > > > I have several questions about what is the right approach do code > > > this: > > > 1. Should I use Box extends SurfaceView? > > > 2. Can SurfaceView gets user events like onTouch/onClick? > > > 3. Is there a way to add to the "main" SurfaceView another SurfaceView > > > (Box)? > > > 4. If none of the above questions is positive, should I use one > > > SurfaceView (and one Thread) and try to map the other Boxes on the > > > screen for user event handling. I mean Box only paints itself but the > > > user event is being handled by me (not by the OS). > > > 5. Should each Box (SurfaceView) should handle it's own Thread in case > > > of animation (it is not good design but it is also an option)? > > > 6. do you have any other proposal? > > > > I know that these are a lot of questions but I'll appreciate if you > > > can answer some of them. > > > > Thanks in advance, > > > ayanir > > > -- > > Dianne Hackborn > > Android framework engineer > > [email protected] > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see and > > answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

