Shooting

Hello guys, a fast question :)

how can i make that if i click anywhere on the screen , the player shoots there. for example i stand at the left side at the screen and enemies coming at me from the right, and i have to click to the direction where i want to shoot the bullet to kill them ..
sorry for my bad english :(

Comments

  • ThoPelThoPel GermanyMember, PRO Posts: 184
    edited July 2015

    That is hard to say without more information (2D? Top-Bottom?).

    Solution 1
    You rotate your Actor to the direction of the touch, after the rotation just use self.rotate as direction.

    Solution 2
    You just use the actor position and the touch position to calculate the angle and use this as direction (relative to screen).

  • SimiglaRolandSimiglaRoland Member Posts: 20

    uhh, that's the first thing in gamesalad i don't understand :O look i give you more info it's 2 d, and i'm in the bottom of the screen and enemies are coming to get you from the top.
    and you have to touch the screen to shoot them

  • ThoPelThoPel GermanyMember, PRO Posts: 184

    Okay, than use Solution 2.

  • skipniceskipnice Member, PRO Posts: 68

    @SimiglaRoland said:
    uhh, that's the first thing in gamesalad i don't understand :O look i give you more info it's 2 d, and i'm in the bottom of the screen and enemies are coming to get you from the top.
    and you have to touch the screen to shoot them

    you're using solution 2 to calculate the angle of he bullet based on your position and the position of the bad guy/or where you tap. so the formula "vectortoangle(tapX-selfX, tapY-selfY) gives you the angle at which you can spawn/shoot at

  • SimiglaRolandSimiglaRoland Member Posts: 20

    sooo RULE/If all of the following are happening | touch is down (i suppose) |do:

    i don't really get the thing :( :(

  • SimiglaRolandSimiglaRoland Member Posts: 20

    i use the windows version so i don't really get that i suppose it's MAC you are using

Sign In or Register to comment.