rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.18k stars 259 forks source link

Remove gaps between jigsaw pieces #455

Open meetpatel1989 opened 3 days ago

meetpatel1989 commented 3 days ago

Hi, I've been using your rexcutjigsawimageplugin. I wrote some code to remove the preFX once a piece is successfully placed in its original position. However, there's still a visible gap between the pieces where the edge was created.

For reference, please see the image below.

image

I even removed the FX from the beginning of the game but the gap is still there.

image

Am I missing anything here?

I know the preFX process is very resource-intensive, and I'm not considering applying it to all pieces because it causes the game’s FPS to drop significantly if I add them to all pieces. However, even when I remove the preFX from the pieces once they're placed, the issue persists. Do you have any idea why this might be happening?

Thanks!

rexrainbow commented 1 day ago

Update minify file of CutJigsawImage plugin, overlap curve of edge, to eliminate gap between pieces.

meetpatel1989 commented 13 hours ago

Thank you for the quick update! Yes, it is working fine now(when I don't use prefx), as shown in the following image.

image

However, if I use preFX, and remove the outer glow when the piece is placed, it works fine except the last row.

Screenshot 2024-07-07 at 6 38 54 pm Screenshot 2024-07-07 at 6 39 48 pm

I'm using an image with a resolution of 540x720 and have the following settings to create jigsaw pieces var pieces = this.plugins .get('rexCutJigsawImage') .gridCut(this.sourceImage, { piecesKey: 'pieces', columns: 5, rows: 7, edgeWidth: 15, edgeHeight: 15, useDynamicTexture: false, createImageCallback: function (scene, texture, frame) { return new Jigsaw(scene, 0, 0, texture, frame) } })

I also didn't get you here: overlap curve of edge, to eliminate gap between pieces

rexrainbow commented 13 hours ago

There have concave edges and convex edges. I draw convex edges larger (more 1 pixel) and concave edges smaller (less 1 pixel), so that they will overlap.

rexrainbow commented 12 hours ago

Here is a test case with preFx outline, works well. Please provide a simplest test example for the latest issue.

meetpatel1989 commented 5 hours ago

@rexrainbow Please get the source code from this link.

https://drive.google.com/file/d/1O81C5JkGCyUaHDwGJ5N-hSNnQzetgyHh/view?usp=drive_link

Using your webpack template :) Just drag the piece and place it in the same place to remove the preFX. You will see the missing pixels on the last row.

rexrainbow commented 2 hours ago

Here is a test case, using your image and setting, It looks well too. 圖片