Math Broblem

0 favourites
  • 4 posts
From the Asset Store
Aliens are invading our planet! Solve the math question, and attack the alien with your laser. Covers addition, subtract
  • i need explanation for how next event should work:

    There is gauge, with dipstick on middle on it, like car's speedometer. Well, this won't work like car one's.

    I need event/fuction/etc, that makes on click dipstick go full 360 degrees spin in X seconds, where X is variable i want.

    For example, like if X is 1, dipstick goes full 360 degrees spin in one second.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try this:

    Let's assume you want to rotate an object "Stick".

    Give Stick a boolean: Stick.Rotating and set it to false.

    Declare variable Stick.Rot_Time = x (where x is the time you want the stick to take to rotate 360 degrees).

    Declare Stick.Start_Angle = Stick.Angle (the starting angle, in case it's not zero).

    Then, when you want to rotate the Stick, set Stick.Rotating = True and use the following code:

    If Stick.Rotating = True:
    

    Trigger once: Set Stick.Start_Angle to Stick_Angle

    Set Stick.Angle to Stick.Angle + (360 * dt / Stick.Rot_Time) -- this will rotate clockwise, use a minus to rotate anti-clockwise

    If Stick.Angle is within 2 degrees of Stick.Start_angle -- this stops the stick at 1 rotation**

    > Set Stick.Rotating to False

    > Set Stick.Angle to Stick.Start_Angle[/code:3ddx4l2r]

    ** It won't work if you want it to rotate in less than 1.5 seconds because that is 4 degrees per tick at 60 fps. If the rotation rate is any faster and/or the framerate drops then it could miss this check window and carry on spinning. If that happens, just use a wider window...

    An alternative would be to have a look at the plugins - you could use Rex's Rotate To plugin for this as well.

  • thank you.

  • Jabutosama, I just had a thought - a tidier way of managing which direction to rotate would be to leave the code as is and just use negative time values for Stick.Rot_Time if you want the Stick to rotate in an anti-clockwise direction. Can't believe I didn't think of that first go!

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