Rotate object at angle - ADVANCED

0 favourites
  • 5 posts
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Ok, it's me again. Guess I couldn't wait to mess up again!

    I put advanced in the subject because this problem goes way beyond just telling an object to rotate and then stop on a certain angle.

    What I need to do is on the menu layout, the needle for the guitar tuner needs to rotate left or right based on certain conditions. This gets complicated, but I'll try my best to explain...

    In my interactive graphic novel, the reader is given choices that determine whether the main character does something merciful or unmerciful and cooperative or uncooperative. For instance, you have the decision to knock someone out or kill them; that would be merciful or unmerciful, respectively. Or you have the option to come along quietly with authorities or you can try to escape; that would be cooperative or uncooperative, respectively. You can probably see where I'm going with this (think the Paragon/Renegade decisions in Mass Effect). The overall outcome of these decisions determine which ending the comic will have.

    Anyway, each time the reader selects merciful, the needle should go about 8 degrees to the right of the center of the tuner. This is also the case with each time the reader chooses cooperative. However, the needle needs to move left 8 degrees for each negative choice as well. For instance, if the reader has chosen (in this order) to be merciful, cooperative and then merciful, the needle should be 24 degrees to the right of center. If the reader then chooses a negative choice (in the way of unmerciful or uncooperative) then the needle will move to the left 8 degrees and thus it will rest at 16 degrees to the right of center until the next choice. Still with me?

    I'm having a really, really hard time figuring out how to do this...pretty much all day working on it. Everything seems to break when I try it...sine, custom movement, regular movement, setting angles, rotating to angle, using instance variables and global variables...blah!

    I don't get it. I'm much better with the design stuff. Any ideas?

    http://philipcomposer.com/comic/sax.capx

  • Have you tried storing a global variable which gets updated, and then on every tick match the angle of the object to it?

    Don't use instance variables as they will reset.

    I haven't looked at the code, but it sounds like it would work to me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, have a global variable called Karma or something then each time the reader selects an option, add or subtract 'Karma Points' from the global variable then set the angle to: 90 - Karma.

    That way if the player has negative Karma, the needle will swing to the left (between 90 degrees and 180) or if they have positive karma the needle will swing to the right (between 90 degrees and 0)

  • The above suggestions are the way to go, I made a quick example for you to illustrate:

    AlignmentDial.capx (r97)

  • Thanks again guys. Confirmed to work with a slight modification to account for being on more than one layout.

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