The background of my game is going to be scrolling. Instead of making it scroll by moving all the objects in relation to my main character, I want to just move the camera to follow him.
I could do that with g.translate(x,y) in java but what is the equivalent in Android?
Also, if you want let me know your thoughts about if moving the camera is the best choice. Why does everyone just make the background move, and not the camera?
Thanks!
I could do that with g.translate(x,y) in java but not sure how in Android.
The equivalent would be c.translate(xPos,yPos), where c is of type Canvas.
Also, if you want let me know your thoughts about if moving the camera is the best choice. Why does everyone just make the background move, and not the camera?
Probably because they are unaware they can apply matrix transformations to drawing operations.
Related
Does someone know how to do complex animations in Android Stuido such as Select-Seats-Payment Animation?
I know there is Open GL for creating Spirtes and so on but do you actually do this kind of complex animations with Open Gl? And also wouldn't that be laggy?
Any hints would be very appreciated! Thanks in advance!
I guess you want to create the flight zoom and rotate animation.You don't need to go to OpenGl level. You just need to learn canvas. All the seats and the flight itself is simply plain design. So no need for bitmaps/images to create them. Create all seats by drawing them and treat them as like separate objects and give them their own properties like click listeners(Clicks should be handled by onTouch() function of the customView). But it takes lots of practice in canvas API of Android.
I'm trying to learn App Inventor 2, by implementing the tutorials and redo some in another way. I'm currently trying to make a compass similar to this, but instead of the classic rotating disk, I want to have a linear display, something like this.
Should the code blocks used in the rotating compass be altered in a way, to have the linear compass effect? By simply changing the displaying image does not work.
I'm currently using this block combination:
"when OrientationSensor1.OrientationChanged
do set Compass.Heading to get azimuth +180 (to get N always)"
Can someone give me a clue on how to implement a working linear compass in app Inventor 2, if it is possible? Thank you all in advance for your answers.
You can draw one yourself using the canvas.
Check this example how to render it, it draws the North mark only, but you can extend it easily to draw all other marks...
Before use I would try if this approach (redrawing the old position of marks) is not slower of faster than clearing the whole canvas (might perform faster).
Good luck.
I am building a virtual store with the effect same like this
enter link description here
The user can freely rotate the image from left to right and top to bottom or vice versa. I suppose to use sprite 2D to implement that animation. There are some tutorials I found but because Im pretty new about graphic programming so could anyone point me to the correct way that approach my expected performance. Thanks a lot.
The easiest way is to use the Canvas API in Android. Here is an example of how to use it with sprites.
I have in my app some sprites.
When I touch a sprite (in TouchEvent.isActionDown() ) , I need to change its image
How can I made this?
I'm not familiar with AndEngine, but by the looks of it, the Sprite class does not provide the functionality to change its image - or better said: texture. However, you might be able to accomplish your goal by using the TiledSprite or AnimatedSprite.
The latter is an extension of the first, so you should be able to use a TiledSprite. It has setCurrentTileIndex() and nextTile methods that seem to allow you to swap out one texture region by another. You may need to modify your images into a format suitable for AndEngine though and obviously you will need a handle to the touched sprite.
I'm trying to create a simple Pegs game. I have drawn the 15-hole board using canvas. I have been programming a while, but games are new to me and I'm stuck on what to do when it comes to handling the pegs. I want to only use the touch screen, but it seems like it is really difficult to touch the pegs and actually select them individually. I plan on just drawing everything programmatically. What is best way on handling this? Using buttons as place holders and changing the button image? Any help would be greatly appreciated.
To be very brief, you have to keep track of the things you draw on the canvas.
I wrote some tutorials for making and moving selectable shapes on the canvas. They should help a lot.
On android it might be a little different than using mousedown, but it should give you a very good starting place.
I don't know if this will help, but you might want to write your own onTouch()function. Check it out