Defense Game
GingerBGames
Member Posts: 390
Hello GS'ers,
Does anyone know of a tutorial or template on how to create a defense game? Tshirt has a great template, but I want to have a cannon on the bottom of the screen. the base be stationary and the barrel be movable. I want to have the barrel move with my finger, but only swivel, not move the entire cannon! I hope I explained this properly for you guys?
Does anyone know of a tutorial or template on how to create a defense game? Tshirt has a great template, but I want to have a cannon on the bottom of the screen. the base be stationary and the barrel be movable. I want to have the barrel move with my finger, but only swivel, not move the entire cannon! I hope I explained this properly for you guys?
Comments
You would just have to constrain the rotation of the barrel to the angle of the line between the cannon base (pivot point of barrel) and the touch. "vectorToAngle()" can get you that, or better yet, use "Rotate To..." behavior to rotate the barrel angle to the touch point.
You may need to make your barrel image twice as long as the barrel to align the pivot point correctly with the "loading" end of the barrel - at the middle of the image (unless you use some of the sin/cos rotation about a circle trickery I use in some of my aforementioned demos).