codah's Forum Posts

  • My idea would be to first have a sprite pinned to the center of snap-able each edge center of each shape. Let's call them "edge".

    Then when a shape is dropped pick the closest other edge that's closest to each of the shapes edges. Of the two pairs of edges only keep the closest. A little tedious to make events for but that would give you the two edges that would need to snap together.

    The snapping could be done by moving the dropped shape by the offset of the edges and orienting them based on the normals of the edges.

    I'm attempting to come up with an elegant event setup, so stand by for a capx.

    Yep exactly what I'm attempting Currently I find the nearest 'shape sprite' to the dropped one, then decide which 2 'edge sprites' from each shape sprite are closest, then do a move-to to bring them together (the shape is pinned to the edge sprite so it moves too). Now I just need to get the angle of the objects right. Thanks so much for your time and I'll be happy to look at any ideas/refinements you have!

  • Looks like you're not actually picking any objects. Just associating UID's is not enough. You're comparing enBox.hostUid = rdSlime.nestUid but at that moment, all enBox's and all rdSlime's are picked. Look into running a For each enBox loop around the system - compare, and inside the loop pick rdSlime by enBox.HostUid. If you had the full version, a Container would do the trick.

  • Hey TheDom thanks for the response. You mean Physics Puzzle? hmm not sure how that fits but perhaps I'm missing something. Could you be more specific? My needs are more like a tangram puzzle where the pieces must 'know' how they are allowed to fit together, and automatically move to the nearest piece and snap onto it.

    I'm also not using physics, although there might be a clever way to leverage physics to do this. I just thought it was overkill. And also it's important my pieces snap together fairly accurately.

    I've just looked at the jigsaw tutorial, but those pieces are arranged on a grid. Mine are arbitrarily placed.

  • If you run your game in debug, click on the sprite in the object tree on the left, you will see the bounding box rotating and changing shape in real time, just like what LittleStain did by creating a sprite to the bbox dimensions. I thought you would've done that before

  • I won't need to do the Log In Browser... but wow that's a cool trick. I didn't know you could do that.)

    um.. that was just for debugging....

    Here is the relevant bit. Not sure how that's complicated..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Firstly sorry for the bad diagram but I think it shows what I need.

    In words, I have certain shapes (not those shown) that can be drag around the layout. When dropped near to another shape, the dropped one should move to, align with (i.e. rotate), and 'snap' to, the shape nearest to where it was dropped. The shapes can only fit to each other in certain way (e.g. along specific edges).

    (I also need the shapes to be dragged off again (un-snapped) and to allow the connected shapes to be dragged as one, but the above is the main thing)

    I'm still deciding whether to have each shape as an animation frame of the one Sprite, or to have different Sprites for each shape.

    I have looked through the FAQ and forums. Some ideas come close, like magnetism effects, etc. I'm running with a couple of ideas involving lots of Pin-ing, but I'm sure there are elegant solutions that I'd not consider.

    Thanks!

  • codah

    couldn't that just be done, using a seperate selection sprite?

    Yep Sorry for the confusion.

  • but after I rotate it, I want it's height/width to be based on it's new angle.

    I'm probably misinterpreting this, but the bounding box automatically resizes based on rotation.. I've just had the reverse of your problem, where I want a visual 'selection' box that doesn't change size as the sprite is rotated, so I can't use the technique used by LittleStain.

  • Pin the sprites to the translucent sprite, then move the translucent sprite with drag drop. That should work fine.

  • I dont think that method has worked for some time

  • I'm using the Function object in the latest version. Can you post a capx?

  • ok then try this

  • I second the motion for Family to support being a container.

  • See update above ^^

  • Assuming it's a 2d array of text and that an "empty" slot will have an "X" in it.

    Array: W=4, H=3, D=1

    Array2: W=0, H=1, D=1

    For "" from 0 to array.height - 1

    Array.at(3, loopindex)) = "X" --> Array2:Push back loopindex on X axis

    Edit: fixed a basic error. see capx. sorry if I caused you more confusion. After re-reading the OP It seems you want to check for "X", not empty cell.