Touching an object in a tweened animation? - android

I'm having trouble porting a simple game I developed for the iPhone
over to Android. The game has an animated ball which moves from Point
A to Point B. The user must touch the ball before it reaches point B
or lose the game. This was easy to implement on the iPhone using Core
Animation since I could locate the current position of the ball by
accessing its animation layer. In Android, I attempted to recreate the
game using tweened animation and represented the ball as a Drawable.
My issue is that I can't determine if the user is touching the spot
because the Drawable apparently bounds do not update as the ball
visually moves - making the program think the ball is always in its
original position. While searching these forums I saw an Android team
dev. confirm that you can't get the current location in a tweened
animation but offered no solution for a workaround. Can I accomplish
this on the Android using my current approach? If not, what approach
should I use?
Best regards,
Michael

Can I accomplish this on the Android
using my current approach?
I doubt it. Android's tweened animations are not really designed for games.
If not, what approach should I use?
Implement the game using 2D drawing on the Canvas -- see the LunarLander sample in your SDK.

Related

Car race 3D object (not image) rotation in android

I want to develop a car race game in which I want to rotate car object (not image) in clockwise direction at the time of car selection. After that I want to change the car object color when user drag the screen to left, like image sliding in Android. I don't know about any type of 3rd party API which is used for gaming development to make it easier. I think that the rotating car must be an animation but As I search Android only supports the animations in the form of XML.
Please refer to OpenGL in Android, i think it's the only reasonable way for you to complete your task and to program any game in general.
This link will help you start: http://www.learnopengles.com/android-lesson-one-getting-started/

AndEngine VS Android's Canvas VS OpenGLES - For rendering a 2D indoor vector map

This is a big issue for me I'm trying to figure out for a long time already.
I'm working on an application that should include a 2D vector indoor map in it.
The map will be drawn out from an .svg file that will specify all the data of the lines, curved lines (path) and rectangles that should be drawn.
My main requirement from the map are
Support touch events to detect where exactly the finger is touching.
Great image quality especially when considering the drawings of curved and diagonal lines (anti-aliasing)
Optional but very nice to have - Built in ability to zoom, pan and rotate.
So far I tried AndEngine and Android's canvas.
With AndEngine I had troubles with implementing anti-aliasing for rendering smooth diagonal lines or drawing curved lines, and as far as I understand, this is not an easy thing to implement in AndEngine.
Though I have to mention that AndEngine's ability to zoom in and pan with the camera instead of modifying the objects on the screen was really nice to have.
I also had some little experience with the built in Android's Canvas, mainly with viewing simple bitmaps, but I'm not sure if it supports all of these things, and especially if it would provide smooth results.
Last but no least, there's the option of just plain OpenGLES 1 or 2, that as far as I understand, with enough work should be able to support all the features I require. However it seems like something that would be hard to implement. And I've never programmed in OpenGL or anything like it, but I'm willing very much to learn.
To sum it all up, I need a platform that would provide me with the ability to do the 3 things I mentioned before, but also very important - To allow me to implement this feature as fast as possible.
Any kind of answer or suggestion would be very much welcomed as I'm very eager to solve this problem!
Thanks!

How to do Translate Animation in android for app development

I got a image ball which is to fall from above continuously on a time frame, the flow has to be continuous and the image should appear continuously as rain falling from above and at certain speed, what is the best way of doing this.
what kind of animation would be helpful, Translate animation or using canvas..help me learn the usage of canvas in android.
How could i achieve this using canvas, any example would be helpful. thanks in advance.
My suggestion is to take a look SurfaceView... As I have found previously SurfaceView gave me the freedom to do anything I wanted and avoid blocking the UI thread. As it has it's own thread, you can specify all kind of time frames and interactions. You can even calculate physics and collisions. HERE is a great tutorial for getting you started.

Android Development- Creating a board game

Im trying to plan out the best way to develop a sample game. I would like to create a board game that act like words with friends (not game rules). For example, I want the board to be a six sided board that has a set number of game tiles. When a game piece (like a checker or ball) is placed on it, i would like to have that piece "snap" to the closest location. My question is, what is the best way to do design the board? Should this be done as a background image? Or draw the board live? If so, how do i create the "snap to" and register when a piece is on the board? I also want to make sure that the board is drawn to the correct dimensions for different phones.
Thanks for any suggestions
jason
This is probably a bit to broad of a question for SO. But I'll give it a go.
Little bit of preface, I have not personally attempted what you are trying. So please do not take what I suggest as what you must do.
If I were you I would create a GameBoard object and a GamePiece object. Put everything to do with making and holding information for the board in the GameBoard class. Whether you draw your board in java, or start with a graphic and build from there depends on a few different things. How specialized would you like the board to look?(you'll have more control if you start with a graphic if you want to make it fancy) If you're just looking for a grid of lines and nothing fancy I'd think you'd be fine to just draw it from java. Do you ever want to use more/less than 6 rows/columns? If you want to use a different number it may be easier to do that when the time comes if you do your drawing from java rather than from a stored graphic. Your game board will also need to be able to keep track of which pieces are on it and where they are.
As for the snap-to: You'll be creating a touch listener that allows you to drag a GamePiece along under your finger. inside of the Finger_Up event in your listener you'll check the piece's current Rect against the Rect's on the GameBoard and drop into whichever slot it intersects most. Fair warning while you are creating your touch listener you're going to have to use some very nitty gritty linear algebra to take raw motion events from the touch screen and tell it where to draw the piece next.

Scaling an android View

ok, I'm going to ask this because I really can not find an answer, after scouring for hours.
I'm making an android game, and I have a gameboard 'view'. My gameboard view has a few things - it has a background image, and then it has a grid of board pieces ontop of it.
I want the user to be able to double tap to zoom in, and then pan around the board.
I've been able to apply a transform in the past to get this effect (on other platforms) but I'm not sure how to do this in Android (I'm still new) - does anyone know how to apply transforms or achieve the above effect, WITHOUT me having to calculate the position of everything in my view?
Please dont suggest Canvas - I want my game pieces to be objects, and I want to be able to listen for 'on touch' events (AKA I do not want to have to figure out what the user touched when they touch the screen). I also want this for Android 2.1+
Thanks for any help ahead of time!!
Unfortunately doing this with views does require recalculating sizes and seems very tedious. I'm sure you know that Canvas has various matrix transformations one can apply.
If this functionality is important to you, I would think that figuring out how to have your Canvas objects receive touch events is the easier of the two paths, given that most games using the Canvas will also be receiving touch events and correlating them with the underlying game models.

Categories

Resources