Making game using image views and layout (not canvas) - android

I have am developing a game in which most of the sprites are static (but animated). I found that using an imageview with drawable background (using xml) is giving me what I want. I may move those sprites based on user touches and have basic collision detection.
When I search the internet about the game development, most sites talk about either game engine or at least canvas/surface view. However in my case, I find deal with the normal android views and layout is enough to get me to going.
Is making a game using layout, image views and views something that is frown up? am I going on the wrong path with this?
Thanks

It all depends on the kind of game you want to make. If you are making a grid based game, ImageViews could be more useful. However, almost no one makes Android games using layouts. Most people choose to use SurfaceView because it allows much more to be done, and in my opinion if you choose to learn it you will make much better games.
Of course, this is all opinion but I know nobody who creates games using the layout editor.

Related

Android UI Implementation Advice Needed

I'm fairly new to Android and I'm working on an application in which one particular section involves a more advanced UI interface than what you would normally create with the stock UI components. I've read through most of the SDK tutorials and I get the basics but I can't see how to implement something like this. I'm not looking for any code, just some advice on what technologies I should be reading about to achieve this.
Here is a mockup:
So basically at the top there is a thumbnail strip that the user can flip through. Clicking on a thumbnail will perform some action. I'm pretty sure there's a stock control for this.
Underneath that I need to be able to create a composite image that can be pinch zoomed and panned and has hotspots that can be clicked (tapped) on. For example, an image of the solar system, in which the background would be static, but the planets need to be placed at runtime and need to be clickable, and the whole thing needs to be pan/zoomable. Support for very minimal animation (eg slow planet rotation) would be a plus, but not necessary. I'm at a loss on what I would achieve this with.
Finally, there are three pull-out panes that contain other content, such as images, menu items, and other media. Basically these just need to be containers in which I can place any other UI content.
I've done some basic Activities so far with simple forms, so I understand the basic workflow of Android, but I'm just not sure what to look at to achieve something like this. Is this a good candidate for a SurfaceView? Is there something else I should look at? I have been a bit afraid to get involved with OpenGL, since I don't really have a 3D background, and I still want to be able to use native components (buttons, listboxes, etc) without having to re-implement them in OpenGL.
Have a look at this for the slides:
http://developer.android.com/training/animation/screen-slide.html
as for the thumbnails you can use a linear layout, with some imageviews and buttons.

What will be the best Android layout or Canvas or SurfaceView, or Cocos2d android?

I am planning to make treasure hunt game which will contain particles effect,animation, Pinch Zoom or double tap Zoom and Scrolling. What will be the best to work with treasure hunt game. I mean smooth zoom , nice particle etc .. and also resources or some example because I am new to android this will be learning process for me. So what should I choose to go ahead with ?
Suggestions with reason will be appreciated because I need to know why canvas not or surfaceview or cocos2d not.
I'd suggest you to use a SurfaceView, because you needn't work with Layouts and XML Files, so it's faster than a custom Custom View or Android Layout, because of it's hardwarenearness.
SurfaceView is also the most common way to draw in games, so you'll find many tutorials on this in the internet()(for example the well done Droidnova tutorial).
It should be possible to recognize gestures with the abstract Surface View class onTouchEvent.
There are also some game engines, which are easy to use and sometimes even have a good performance, but they are often bad documentated and debugging is hard, if you doesn't know the underlying source code, so I wouldn't suggest them.

Do I need to use layouts when developing games on Android?

I'm new in Android development and I have been making a tutorial for a game example which tells that using a layout file is not necessary because of the flexibility need on game development. However I've seen on Android docs that using a layout file is always the best way for Android development.
I'm sorry if my doubt looks obvious or kind of weird, but I'm really newbie and I'd really appreciate if you guys give me some help.
Most Android Games will use a Surface, Canvas, or GL Surface view to render all content to the screen. This element is likely to be fullscreen as well.
And so all drawing of UI and buttons and game elements are drawn directy to the surface, bypassing the use of Android's many UI views.
There is no reason you game cannot use android UI views in addition to using a surface for drawing the game action itself.
And of course you will likely use layouts as well when integrating things such as Admob ads or user dialogs within you game. So in practice you will use both.
But a standard utility application built in android will use layouts almost exclusively.
As a final aside, it is not necessary to use layouts. Every view type can be created either through XML layouts and inflating the views, or by instantiating a view in java code. the main reason for using layout files is because they are fast to build easy to use for a large category of interface design. But he choice to use them or not is your own.
A layout is used for arranging views. If you're not using any views (i.e. you do all the drawing yourself), then there's no point in using a layout.
For game development you are better off not using a layout file. The tutorial you are following is right. You will probably want to draw directly to a GL Surface View.
Personally, I forgo a lot of the features of the Android framework when doing game development. I use one Activity to bootstrap the game and get it running, and I draw to one GLSurfaceView. A lot of Android game dev tutorials follow this approach, and so are probably going to be a lot more useful to you than tutorials for more traditional Android apps.

What containers/classes do I want to use for the following android game?

I am programming an android game that has a screen, which has a ScrollView that contains almost everything on the screen. I need to have image elements that move around, can be clicked on (but also be transparent to clicks in certain situations) that have multiple layers and animations.
Should I use layered Imagebuttons? there can potentially be doezens of them on the screen at once, and i don't know if there are memory concerns about having 200 imagebuttons on a screen.
Do I need to use a canvas? I have seen canvases in many examples, but i don't know if they are the best option.
Is there some other class or way of doing this that is better?
any help you can provide would be much appreciated.
You'd be best served by an Android game library. Check also e3roid.

How do I implement an application similar to google maps on android?

I have a couple of images on available to my program. They are parts of jigsaw puzzle (with rectangular pieces though). I wanted the look and feel similar to that of google maps in android.
One way I could implement was to create a set of ImageViews and keep recycling them, as the user pans the image in any direction. However, to me that appears like a brute force method. Is there any alternative approach to implement such kind of application?
Or rather how is google maps implemented? A set of Imageviews ?
I think for your case the OpenGL route might be the best choice. You can get started with the GLSurfaceView.
Using set of images and recycling them is a valid method. But you can enhance it by adding some redundant ones to keep close to view area images preloaded.

Categories

Resources