Defense Game

GingerBGamesGingerBGames Member Posts: 390
edited November -1 in Working with GS (Mac)
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?

Comments

  • rebumprebump Member Posts: 1,058
    Codemonkey has tank turret demo. I also have a few demos that feature a moving item about a central point...actually many (like my lightsaber demo for integration into Codemonkey's dual joystick demo). Although these may be more than you need.

    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).
Sign In or Register to comment.