How do I change sprite origin runtime ?

0 favourites
  • 5 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • I'd like to change sprite object origin runtime. I have multiple instances of an object and at a certain point of the game, gravity is applied and I want every instance to fall with a rotation applied to a different part to every instance. Image leaves falling from a tree or pieces of paper detaching a the same time form a board where they are pinned.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don’t think you can change it even with js. The origin is tied in with the frame which is shared between instances.

    You can rotate around an arbitrary point cx,cy by and angle a with

    sprite: setpositiom to (cx+(self.x-cx)*cos(a)-(self.y-cy)*sin(a), cy+(self.x-cx)*sin(a)+(self.y-cy)*cos(a))

    sprite: rotate clockwise a degrees

    You could pin another sprite on the sprite to be the center to use for cx,cy

  • I don’t think you can change it even with js. The origin is tied in with the frame which is shared between instances.

    You can rotate around an arbitrary point cx,cy by and angle a with

    sprite: setpositiom to (cx+(self.x-cx)*cos(a)-(self.y-cy)*sin(a), cy+(self.x-cx)*sin(a)+(self.y-cy)*cos(a))

    sprite: rotate clockwise a degrees

    You could pin another sprite on the sprite to be the center to use for cx,cy

    I'm taking note of this! Thanks :)

    I learn a ton just reading the threads on this community.

    Could this also be achieved by having multiple image points. Then choose a random image point, to rotate on clockwise or counter-clockwise?

  • Sure you could use imaginepoints too. There are probably other ways to get a point to rotate around

  • Thanks R0J0hound

    I'll explore this.

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