Precise Rotating + Pin Behavior

0 favourites
  • 4 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.
  • Hey Everyone,

    I've been struggling with this one and any help is appreciated.

    I'm trying to create a puzzle game where there are pieces on a board/grid that are influenced by gravity(towards bottom of screen). I want to be able to rotate the board/grid (90 degs at a time) with all of the pieces maintaining their relative position. Once the board has stop rotating, the pieces should fall according to the gravity (still towards the bottom of the screen even though the board has rotated).

    I have 2 issues:

    1. Is there an easy way to rotate an object using the Rotate behavior until it reaches an exact angle? Since I am rotating 90 degs at a time, I need it to be precise. I think I created a good work around but it may also be causing my second issue.

    2. I am pinning the pieces to the board when I rotate it, then unpinning them when they need to fall towards the bottom of the screen. However, I can not get the pieces to remain preciously where they should be relative to the rotating board as it rotates. They seem to always want to slip slightly to the left and this causes problems with alignment.

    Here is a link: dropbox.com/s/yn3f2ce4ntwfr7s/Rotate_Pin_Unpin.capx

    Let me know if you have any suggestions.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • BreadCrowns

    Hi, not got much time at the moment but the first thing i see is your Blue blocks are 258 x 258 which means the image point is in the wrong place.

    Will check out the rest later if no one else gets there first <img src="smileys/smiley1.gif" border="0" align="middle" />

  • spongehammer

    Thanks for taking a look!

    I did mess around with image point a bit but it seems like the piece still shouldn't move like it is. If the image point is off center then it will rotate a little oddly but the image point should always remain the same distance from the center of rotation.

    I'm actually surprised I'm having as much trouble with this as I am. I thought this would be pretty straightforward, but I'm still new to Construct so I'm wondering if I'm missing some really obvious thing.

    Thanks.

  • BreadCrowns

    As far as i can see there is nothing wrong with your logic. The pin behavior may not be accurate enough.

    Also the detection you are relying on is not ideal either. Part of the problem is that if anything is out on the first rotate then its all compounded from there.

    I would suggest a different approach to moving the blocks, more like moving each one a set distance from the center of the current square to the center of the next. This will do away with relying on the collision detection.

    When i get a few mins free i will make a capx to show what i mean.

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