Set center point runtime

0 favourites
  • 7 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi all,

    I want to know if somebody has a trick or a way to set the center point (0) on runtime?

    Because I want to "pin" some runtime created sprites and in some of than the middle is not the point I want!

    Thanks

  • You can't change the origin at runtime, but why not use multiple image points, and just pin to them as needed?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure I understand what you mean by runtime created sprites. If you want to pin object A, to object B, your are going to pin the origin of A to maintain relation to object B, so A does not stick to the origin of B, it just keeps it's relative position to B consistent to where it was before pinning.

    If you move A 20 px to the left of B and then pin, A will be kept at 20 px left of B (well, rotation is also taken care of in a smart way).

    Here's an example of attaching A to B, when you don't care about what origin B has: dl.dropbox.com/u/10338488/pin_to_not_center.capx

    I hope this solves your pinning problem, as I don't see how changing the origin of A could have any affect. Say you have a sword, and you want to hold the sword by the handle (so you put the origin in the handle when you have it attached to a character). If you want to stab the enemy and have the sword stay in the enemy, if you position the sword such that the tip is in the enemy, and then pin it, it would still work perfectly. Rotation and all taken into account.

  • GeometriX and laserbeam

    Sorry the long time to comment, but just after I do the post, I had a fever in all day long! Now I am better so let me explain again.

    The trouble I have is because when I "LoadURL" an "sprite", it come with the origin at the center. If the "sprite" is a arm, when I "pinned" it to the torso it rotates at the center, instead of in the shoulder.

  • Ah, you should've said that these are loaded sprites.

    In that case, you can't do anything with the sprite itself, but you could create an invisible dummy object that's pinned to the loaded sprite's origin, and set up with its own image points that can be pinned to.

  • GeometriX

    Yes I already think in this way, but is complicated for many objects.

    Thanks anyway

  • Another option would be to create your own pinning system using events. You'd have to use a bit of trig, but it should give you the flexibility you need to position objects based on a loaded objects center origin.

    Having said that, I think GeometriX's suggestion of using an invisible object would work just as well, and be much simpler to implement.

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