How do I make pinned sprites inherit behavior?

0 favourites
  • 12 posts
From the Asset Store
Pin UI
$2.49 USD
Create a perfectly Pinned Interface for Any Device
  • Hi, trying to create a classic Jigsaw ''torn-up note'' for my game. I got as far as giving each piece of the note the pin behavior and the drag and drop behavior.

    Then, I made sure that when you click a piece it goes to the top by adding ''Move to top of Layer", and the ability to turn them 90 degrees on right-click.

    Then came the harder part. If I drop i.e. Note piece 1, it needs to connect to Note piece 2 when in range and at the right angle. So I gave both an image point at the edge and used the "Set Position" with: NastyNote_2.ImagePointX(1) - NastyNote_1.ImagePointX(1)-NastyNote_1.X) (NastyNote_2.ImagePointY(1) - (NastyNote_1.ImagePointY(1)-NastyNote_1.Y). Again, this works. Nice!

    Then I used the pin behavior to first determine the distance where piece 1 should be pinned to piece 2 by using: distance(NastyNote_1.ImagePointX(1),NastyNote_1.ImagePointY(1),NastyNote_2.ImagePointX(1),NastyNote_2.ImagePointY(1)), and then I pinned the pieces to each other. This works great as well.

    Now, my issue is that when note piece 1 is pinned to note piece 2, only note piece 2 remains functional. What I want to achieve is to get all the pieces that are pinned together to the top of the layer when clicked, just like the individual pieces when you click them, and I want the thing to be draggable as a whole unit no matter where you click. Those are the two final issues with my puzzle. So essentially I would like the pinned pieces to follow up on the behavior of whatever piece is selected, or I want to make some type of new object from the pinned pieces if possible.

  • I kind of understand what you're doing but why are you using pin, why do they need to be pinned?

  • Hi, thanks for your question. It's because I have no frame or boundaries other than the screen resolution. So you can drag and drop all pieces including those already connected. To keep them connected I use pin.

  • Just to visually clarify what I'm doing, and I also just noticed that as it is now, I can only pin the relative bottom/left piece to the top/right piece and not the other way around or a single piece in all four directions, as it simply unpins the last pin if it was already pinned which causes issues when you i.e. pinned the top left piece to the right adjacent one, and then you want it to pin to the bottom adjacent one (it will unpin the right piece again).

    But anyway, my previously described issues remain to be true.

  • It's still kind of difficult to work out what's going on and why Pin behaviour is necessary. You are dragging sprites around then you use set position right? What does the addition of Pin do? To relate them to each other you can use instance variables, objects that have the same value can be picked and move together.

  • It's still kind of difficult to work out what's going on and why Pin behaviour is necessary. You are dragging sprites around then you use set position right? What does the addition of Pin do? To relate them to each other you can use instance variables, objects that have the same value can be picked and move together.

    The addition of Pin makes sure that when you pick them up the ''newly created'' filled in piece of the puzzle moves as a whole. Could you give an example of how to do this with instance variables? Cause that got me confused.

  • I don't know fully how your game works but if it works where pieces fit together to form a more complete piece, you can have one piece on selected for drag, pick all the other pieces where the instance variable is matching and pin to that piece, they would move together. So pieces that are already correct and set to move would have instance variable value 1, and ones that are not correct are 0. The pieces set to 1 would move with the one you are dragging.

  • 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 answer, I know what you try to do but the issue is more that I would need something to check which specific pieces are connected to the one you are picking up. Just like with a real puzzle, you could start with any piece and start building the final image from that one. But if you would start with say, the upper-right corner and you connect four pieces there, and you then find the lower-left corner and also start connecting pieces there, you already have two different draggable connected sections. When I use your possible solution I would essentially give all those connected sections the same variable and they would all drag over the screen whenever I drag a single connected section.

  • You can identify the various sections, once you have a starting point the top left could be var=1, the bottom left is var=2. Anything that connects to the bottom left is 2 and the top left is 1. Well it sounds easy, depends if it works for your game.

  • I understand, but there is no specified starting point, meaning any piece or connecting two pieces could be the starting point. But perhaps I could make a variable that tracks if the imagepoints (the connecting points) are within 1 pixel range of each other AND if the object is pinned, and if both conditions are true I could give those pieces a variable of i.e. var=1. I might try this later today and get back to this post if it works.

  • Yes there must be a point where you say 2 pieces are correct or true and pin to each other, at this point you set identifier variable value to distinguish them from the rest.

  • Hey, just wanted to update.

    I tried to make it work for too many hours, but it's one of the elements of Construct that honestly kind of sucks. Sometimes it would be nice for certain options to have more sub-options, where the pin behavior and the drag and drop behavior only let the pinned-to object be dragged as an example (where I would like them to both move and I wouldn't even have had to create this topic). Or a better group possibility.

    Instead, tutorials for Jigsaw puzzles that I checked have messy and difficult workaround where variables serve the purpose of grouping together pieces with a common pin object that keeps on being destroyed and created, after which the dragging doesn't look clean either.

    It's one of those things that I would like to see managed differently, even more user-friendly like the RPG Maker series in a way.

    ANYWAY I'm sidetracking, I simply made a frame for the puzzle and linked the pieces to their appropriate positions instead of linking them to each other. It's not as elegant as I would have wanted but it works. Perhaps in another update I will get back to it!

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