How to rotate a wheel with touching (spinning it)

aalzankiaalzanki Member Posts: 283
edited November -1 in Working with GS (Mac)
How to rotate a wheel with touching (spinning it)
I want to rotate the wheel by spinning it to the right or to the left, and i don't want the wheel to move I only want it to spin.
Thank You.

Comments

  • aalzankiaalzanki Member Posts: 283
    No, I meant i want to spin it with my finger
    Thank you
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    not sure about this, but...

    when touch is pressed
    constrain self.rotation to VectorToAngle (game.touch1.X, game.touch1.Y)

    if this doesn't work try:

    Create two integer game attributes spinX and spinY

    Create an invisible actor with rule:

    when touch is pressed
    constrain self.positionY to touchY
    constrain self.positionX to touchX

    constrain game.spinY to self.positionY
    constrain game.spinX to self.positionX

    In the spinning objecting:

    When touch is pressed and inside
    constrain self.rotation to VectorToAngle(self.positionX-game.spinX, self.position.Y-game.spinY)

    Hopefully one of these will work or will at least get you going in the right direction!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    I would have no idea how to give it momentum like a wheel of fortune wheel.
  • beaudoin_nbeaudoin_n Member Posts: 184
    I have a similar question for a future project (well if i can finish the first eventually!)

    Would it be possible to have 2 fingers touching the objects and rotate accordingly as where they move.... if you played enigmo that same movement
    i think it is also used for photos when you have them in a kind of desktop arrangement,,,saw that with the sixth sense project.
  • aalzankiaalzanki Member Posts: 283
    Thanks guys.
    it worked
  • adadoadado Member Posts: 219
    @beaudoin: With that type of mechanism, since the rotation of the object by way of the two touchpoints would be continual, you would want to sense two touch points and then constrain the rotation of the actor to the vectorToAngle() value of the two touchpoints.

    Something like:

    vectorToAngle((TouchX2-TouchX1), (TouchY2-TouchY1))

    I think that would work.

    You could even maybe constrain the X and Y position based on the midpoint of the two touches. Although, upon initial touch, you may have to establish a baseline rotation and/or X/Y position to work from.

    EDIT: Actually, upon further reading of this thread, it looks like Scitunes may be doing a bit of all this so play with his example. If you don't constrain, then you will have to wrap your updates in a fairly frequently occuring timer and that could still produce a choppy effect. For the flick-of-the-wheel as the original poster asked, TSB's non-constrained would be best since it is a quick, one-time (so to speak) movement.
  • aalzankiaalzanki Member Posts: 283
    Ok guys thanks for the answers but i have another problem:
    I used Scintunes second example, but i want if the wheel rotates quickly move the other actor quickly and if it moves at a low speed move it at a low speed and if you stop rotating stop the other actor how ?
    regards,
  • adadoadado Member Posts: 219
    Some ideas:

    Time between each touchpoint to determine speed (i.e. less time=faster slide=more speed)?

    Generic single touch to stop (or very little movement between touch and release...use magnitude()).

    Angular drag to eventually slow things down for a more realistic feel.
  • aalzankiaalzanki Member Posts: 283
    sorry but i'm not that good so can you explain a little bit more please?
    I have a wheel and a flag so i want when the wheel rotate the flag move upward.
    Regards,
Sign In or Register to comment.