How to move background image in Android Cocos2d - android

I am trying to move background image from upward to downward direction on cocos2d so that the fixed character sprite seem to be moving in upward direction.
Can any body tell me how to do this.

The easiest way would be to have two Sprites of screen size . move the sprite from upside to down and the give the position start of second sprite to the endposition of first sprite, this way you can have continues loop of background images.

Related

Android Box2D how to make the collision work while changing the circle position?

I'm new in Box2D lib and also new in GlSurfaceView so I need your help!!!
I'm using the Box2D lib with android GlSurfaceView, and I'm trying to implement simple touch and move effect for my bubbles. I've successfully converted the android screen pixels to box2D world points and I can move the circles as expected but the collision doesn't work,,, In this case (the circle which I'm moving) can touch the other circles without any collision. What can I do to make the collision work?
When I'm changing the circles position with applyForce or applyLinearImpulse then the collision works fine, but the collision doesn't work when I'm changing the position with just setting the x and y coordinates.
How do I move a body/actor by dragging the mouse/finger?
The other circle might be sleeping and unable to detect a contact, try disabling sleeping.
circleBody.setSleepingAllowed(false);
i.e. because teleportation is outside of box2d collision resolution the circle doesn't wake up automatically as it does when its collided with normally.

Android Studio - What are possible options to overlay two images and make only the right or left half of each image visible?

I am trying to have two images overlayed in two imageViews and when i start a swiping gesture the upper image is cropped vertically at the starting point of my touch gesture and the cropping line follows my gesture on screen to the left or right. When I move my finger to the right the cropping line should follow it and reveal more of the upper image for example, until I lift my finger from the screen. The crop should stay there then.
The goal ist to be able to compare two images with a swiping gesture.
I hope what I am trying to achieve is halfway understandable and I would be happy about any kind of input regarding that topic ;)
Thank you in advance

Parallax Background with a moving non repeating sprite

I'm using AutoParallaxBackground (from the AndEngine example) to create a background (only 20% of screen height), that appears to be moving. It works, but now I would like to add a Sprite that also moves in X direction, but isn't repeating.
The sprite should be positioned behind the background.
How can I achieve this?
I tried setting the Z index on sprites, but it isn't working, probably because the background is always the lowest.

Making a user able to interact with a "ball" on the screen?

I am trying to learn some more about gestures and graphics in Android, so I am trying to make a sort of game where you start with a ball (just a red circle) in the middle of the screen, and if you swipe in a direction, the ball will be launched in that direction, bouncing of the screen etc. Now, I have succeeded in detecting when somebody swipes in a certain direction, and currently I just display the direction on the screen. My question is: how do I continue? How can I draw the ball, make the user able to move it and make it bounce off the sides of the screen? I think I need to use onDraw somehow, but I'm not sure.
There's a guy with similar problem, he has managed to get circles going around the screen and bouncing from the edges, you may use his code as a basis for your drawing and animation routines: Moving circles in android

View Animation (Resizing a Ball)

i am trying to do this:
1) user long touches the screen,
2) a circle/ball pops up (centered around the user's finger) and grows in size as long as the user is touching the screen
3) once the user lets go of the finger, the ball (now in its final size) will bounce around.
i think i have the bouncing around figure out from the DivideAndConquer example, but i am not sure how to animate the ball's growth. i looked at various view flipper examples such as this:
http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html
but it seems like view flipper is best for swapping two static pictures. i wasn't able to find a good view animator example other than the flippers. also, i would prefer to use images as opposed to just a circle. can someone point me in the right direction?
thanks.
Here are two simple tutorials to help you get started with drawing basic animations including touch input: balls bouncing randomly around the screen and basic drag and drop.
In brief: You're right, ViewFlipper is really not suited for this. You want to draw on a Canvas by making your own custom View. This is the basic framework for 2D graphics. Canvases let you draw image files, solid colors and other things to the screen, while applying transformations ot them at the same time. Handling the user input (i.e. the finger on the screen) is done via the onTouchEvent(...) method, which lets you do something when the finger touches the screen, moves on the screen or lifts off. Have a play with those two tutorials, they should give you the basics.
If you're using a bitmap on a canvas to draw it
http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap(android.graphics.Bitmap, android.graphics.Matrix, android.graphics.Paint)
Use a scale matrix, the identity multiplied by the scalar of the size you want the image to be.

Categories

Resources