Set Pivot Point of a sprite

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hello everyone,

    Is it possible to set the pivot point (or hot spot) of a sprite to a certain value?

    I'd like to have multiple objects rotate around the same axis.

    Thanks in advance,

    Maarten

  • I think this is possible, have you tried "Set current frame pivot point" under "Animation" actions for the sprites? If you don't need this to work at runtime, clicking the red target in the image editor will let you place one as well. Hopefully these work with co-ordinates outside of the object itself.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for your reply! It worked, but not as I expected it to work. What I'm trying to do is this:

    I have 3 sprites and want to rotate them in a way that their relative position and angle towards each other stays the same. Something like this:

    <img src="http://img857.imageshack.us/img857/7663/examplevy.jpg">

    Is it possible to create some kind of parent to do this?

  • Ahh, that takes some math, no problem though since I had to do something like that before

    Here is how to have them always stay at the same point relative to a base object.

    X position of point/object to attach to base:

    Mech.X - distance(WeaponSlot.Value('XOffset'),WeaponSlot.Value('YOffset'), 0, 0) * cos(Mech.Angle + angle(WeaponSlot.Value('XOffset'),WeaponSlot.Value('YOffset'), 0, 0))[/code:2i1cs2vl]
    
    Y position of point/object to attach to base:
    [code:2i1cs2vl]Mech.Y - distance(WeaponSlot.Value('XOffset'),WeaponSlot.Value('YOffset'), 0, 0) * sin(Mech.Angle + angle(WeaponSlot.Value('XOffset'),WeaponSlot.Value('YOffset'), 0, 0))[/code:2i1cs2vl]
    
    Where XOffset is the constant X offset from the base at the normal angle,YOffset is the constant Y offset from the base at normal angle and Mech is the base object.
    
    Then you just change the angle of the blue bars to the angle of the base!
  • Wow thanks, that looks a bit too complicated for me to come up with at the moment. I'm having a bit of a hard time to understand it.

    Am I right that the WeaponSlot is the base object and the Mech is the object that you want to rotate with the WeaponSlot? And did your create a variable with the XOffset and the YOffset of the WeaponSlot?

  • Wow thanks, that looks a bit too complicated for me to come up with at the moment. I'm having a bit of a hard time to understand it.

    Am I right that the WeaponSlot is the base object and the Mech is the object that you want to rotate with the WeaponSlot? And did your create a variable with the XOffset and the YOffset of the WeaponSlot?

    Heh, almost (WeaponSlot is the object that rotates around Mech) and yup, XOffset and YOffset belong to WeaponSlot.

  • Sorry for taking so long to get this straight, I'm still doing this wrong.

    Maybe you can help me by taking a look at the .cap: https://rapidshare.com/files/460290723/rotating.cap

    Thanks a lot for the help so far!

  • You could always use image points.

  • Well I currently have no idea what I'm doing (I'm just doing what JayJay suggests and haven't figured out how it works yet). So if you have a better suggestion, please do tell me.

  • Ah, that's saved in a newer version of Construct. I'll make a cap of my own to show you (I don't want to update until I have time to make sure my game project will work the same in the newest version). Hopefully I'll have it ready in the next half hour.

    Edit: Here is the example of my method, I'll try it using image points as I think that should work too and upload that here in a bit.

    http://dl.dropbox.com/u/4714446/Rotate.cap

    Edit 2: Alright, that was much quicker to make Although this method has some disadvantages (you can't reposition the arms at runtime, or load custom offsets from files, etc). Still, this one should be much easier to implement if you want the arm rotation to be hard coded.

    http://dl.dropbox.com/u/4714446/Rotate%20Method%202.cap

  • Image points are esentially the same as what Jayjay is suggesting, except you cant change them during runtime.

    http://dl.dropbox.com/u/666516/multiimagepoints.cap

  • Wow thank you both very much. I'm going to look into both examples to see which one suits my needs best. I understand how the first example works now, it was a bit too difficult for me to read the code you posted. But after seeing the .cap it's a lot more clear!

  • Where is Set current frame pivot point, no sign of it anywhere, i suppose ill have spent hours finding it before this get answered

    try adding this info in , it's very helpful

  • Set current frame pivot point is heading but no explanation as to what or where this is. That would be very helpful for people.Thanks

  • Daniel Gadd

    Set current frame pivot point is heading but no explanation as to what or where this is. That would be very helpful for people.Thanks

    You are posting in a 4 year old thread, for a discontinued piece of software.

    Is this deliberate?

    Are you asking a question about Construct Classic (discontinued) or Construct 2 ?

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