Mouse and ISO movement

0 favourites
  • 10 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi guys and gals. I'm hoping you can help, it seems so simple but I can't seem to get it right. What I want to do is for a condition check for the right mouse button to be down. For actions what I want is for my sprite to move towards the mouse but also start the correct animation within the sprite.For example:

    condition on right mouse: action: down move sprite 1 pixel toward andgle(spritex,spritey,mousex,mousey) if angle <=22.5 or >= 337.5 set animation "runningeast" play from beginning.

    But when I do it that way it moves the sprite but the animation doesn't trigger. Does anyone have any work around for this? Pretty Please :) Pretty please with cheese on top. :)

    Thank you in advance,


    PS this doesn't seem to work at all:

    <img src="" border="0" />

  • It's because when those conditions are met, on every single tick it will just keeps resetting to the first animation frame because you have it as 'play from beginning'

    changing it to 'play from current frame' would solve it, but then it would still be unnecessarily setting it's animation every tick still.

    A better option would be to make a sub event under this with the condition: 'trigger once'. Alternatively, have a condition to check to see if Knight animation is not equal to "RunningEast"

    Either way it will then set the animation and let it play after the first tick.

    Also make sure animation properties are set in the image editor

  • Thanks I did get it to half work. I'm going to change to what you suggested but for the movement I'm still having an issue. When I check for the angle above the mouse doesn't move. When I check for an angle less than say 5 then if the mouse is anywhere above the sprite it moves east. What am I doing wrong with the condition, or is there a better way then I have posted?

  • angle(knight.x, knight.y, mouse.x, mouse.y)

    The angle is between 0 and 180 when the mouse is below the knight. And between 0 and -180 when the mouse is above. If the mouse is directly above the knight, the angle will be -90.

  • Think I got it figured out. I shouldn't have put the angle as a condition because it wasn't comparing the angle, simply grabbing the angle. So I updated the code using the recommendations here and it seems to work. Heres a pic of it now, does it look ok? src="" border="0" />

  • can't seem to make an or block that will allow multiple conditions between each or so I had to post a seperate statement for each angle variance. Unless you all know of a better way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright I think I got it. Please feel free to tell me if there is an easier way. Here's a snap of the current formula:(Note I turned off the change angle on the sprite for the ISO image. If I leave it on the images do not come out right so I added a variable called currentangle to the knight sprite to track the current moving angle)

    <img src="" border="0" />

  • This looks very similar to something I did for a jumping animation, where it's frame was decided by it's angle of direction.

    The only different thing I did was use "angle is within 45deg of .." instead of the two greater/less than conditions... one less condition

  • use "(angle+360)%360" to keep any angle always a positive value. Then you can deal with just positive angles and let you add/subtract from angles but still keep the value as an angle. Subtract 90 from an angle to get the traditional "up is 0" angle.

    Also you can divide an angle by 4 to get up,down,left,right and divide it by 8 to get those and values inbetween.

    That should help ya get more easily useable values from general angles. Specially when it comes to stuff like animation and determining directions

  • or use an absolute value with abs()

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