What should I do so that it can work in a rotate angle?

0 favourites
  • 7 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.
  • I created a Popup animation using the 'Destination out' Blend mode:

    PopupAnimation.c3p

    But I want to go a step further and make it work even while different angles, I don't know how to get it to work correctly. I think there should be some kind of math formula to calculate it

  • I recommend using an invisible "target" helper sprite , and having your mask object move to the target's location.

    If you use a helper object, you have many options, like spawning it in a container with the base object, pinning it, or using the move at angle action to position it.

    By math, the formula to get a point from a set distance and angle from another point is:

    Target.X = Origin.X + (distance/cos(angle))

    Target.Y = Origin.Y + (distance/sin(angle))

    Although you have to make sure not to divide by 0, and sin and cos can definitely end up as 0 so I'm probably missing something there...

    Edit: Brain no worky in the middle of night.

    Target.X = cos(angle)*distance+Origin.X

    Target.Y = sin(angle)*distance+Origin.Y

  • I'd imagine you could do it by setting the position and angles to each other and just using the move at angle action?

    I think you meant to use multiply instead of divide in that formula to find a point from another one.

    I only use the free version so I can't use too many layers, but here's another idea to do the masking with distort meshes and it just works with any angle.

    dropbox.com/scl/fi/big4tehj919tkonckmj3l/whackamole.c3p

    For the motion I'm using a spring which can be done with three variables and two actions:

    add 0.05*(self.goal-self.t)/dt-0.16*Self.vt to vt
    add vt*dt to t

    The first number is the spring stiffness from 0 to 1.

    and the second is the damping from 0 to 1.

    I tuned it so it overshoots the goal a few times, but if the damping is increased it won't do that.

  • I recommend using an invisible "target" helper sprite , and having your mask object move to the target's location.

    oosyrag Thank you! I'll try again

    but here's another idea to do the masking with distort meshes and it just works with any angle.

    R0J0hound This is magic! Really cooooool! It works perfectly!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I Modified R0J0hound's example but using Tween to control

    MeshPopupAnimation.c3p

  • I have one more question about this:

    issue-Tween-CustomAction

    I want to save the part of set mesh in a custom action. But if I use this custom action that will be used when the Tween is playing, it will produce different results.

  • You probably need to use a for each in there with custom action

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