Question

guys i am new to andengine so i am sorry if what i am asking is straight forward. so my question is i want to make a chicken lay a egg when i press a button. an egg sprite should fall out of my main character when i press a button. it would be really help full if you guys give the idea how do it it or show me thank you. i tried making button with a sprite and connecting it to the hud so it works fine but i dont know how to impliment its fucntion to when ever i press it a sprite should fall from my character help.

Was it helpful?

Solution

First take a look at this: AndEngine Tutorials

Be sure you have the latest AndEngine, I'll advise you to use AnchorCenter branch, where by default all your sprites will have thier anchor center in the middle of "their body". After that just create 2 sprites, the Chicken (C) and the Egg (E) both with the same position but with different zIndex where the C will have a higher one, so that the E will be behind hidden. Then override the C sprite onClick method (the C could be a ButtonSprite instead of a simple Sprite). To move the E you could use an EntityYModifier with the desired offset.
This is the main idea ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top