How do I make sprite face same way it is moving.

0 favourites
  • 6 posts
From the Asset Store
Fully animated four directional dungeon guards pack
  • So recently I am having trouble with my sprite that is supposed to go down, but every time I make it face down and I test it, it moves to the right. If I make it face right, it moves up, face up, moves left, face left, moves down. Is there some reason for this? Even if I change the direction in the event sheet, it still does this. It would be much appreciated if you can give me a list of what could be wrong.

  • So recently I am having trouble with my sprite that is supposed to go down, but every time I make it face down and I test it, it moves to the right. If I make it face right, it moves up, face up, moves left, face left, moves down. Is there some reason for this? Even if I change the direction in the event sheet, it still does this. It would be much appreciated if you can give me a list of what could be wrong.

    please post a capx

  • dropbox.com/s /9u1odbf23nwohce/ Shoot%20Game.capx?dl=0

    Sorry for the late reply. There is spaces between the second "s" and slash mark and also one between a slash mark and shoot.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • hi Flipop I tried the capx, I did not find anything strange, apart from some lines of code of which I honestly do not understand the utility, the sprite seems to move correctly. what's the problem? do you want it to turn in the direction you are pressing?

  • Hi Flipop

    I'm guessing from your capx that you've added events 7-10 to keep the player ship facing up?

    If you want the player ship to face in the direction of movement, rotate the image 90 degrees clockwise in the image editor; 0 degrees starts at 3 o'clock, so if your ship is facing up in the image editor then it's pointing at 270. Be aware that when a bullet is created you will have to set its angle to the ship angle.

    If you want to make your ship always face up the screen, keep the image facing up in the image editor (as it already is) and in the player object's 8-direction change the "Set angle" setting to "No".

    Couple of other issues:

    1) In event 6, you don't need to set the bullet and enemy direction every tick, just when they're created.

    2) In event 11, you only want this to trigger once. To be honest I wouldn't use a wait action here at all. Instead I would add a condition to your keyboard input to only fire a bullet if the bullet value is greater than 0.

    I've created a revised project for you that simplifies the code:

    https://www.dropbox.com/s/n6x6kdtqc0hzs ... .capx?dl=0

    Here are some of the main changes:

    1) Instead of having a trigger for each keyboard input, I have one trigger that checks for any keyboard input, then a check to see which input was made. This reduces the requirement for multiple trigger checks.

    2) I added a condition to this event so that it only fires if the number of bullets is greater than 0.

    3) I used the following expression to determine which image point to fire the bullet from:

    int(Keyboard.StringFromKeyCode(Keyboard.LastKeyCode))

    This checks the last keyboard input (Keyboard.LastKeyCode), then converts it into a string (Keyboard.StringFromKeyCode), and then converts that string into an integer (int).

    4) I set the bullet direction when it's created, based upon the player direction.

    5) I set the enemy direction when it's created.

    6) I've set the parallax of the text layer to 0,0. This keeps the layer fixed and the text object in the top left corner.

    Hope that helps! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Thank you for the replies.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)