DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

Preventing Double Merges in a Fruit-Drop Physics Game

A reliable fruit merge is a one-time transaction: validate matching types, mark both bodies unavailable immediately, then remove, replace, and score once.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To prevent a fruit from merging twice, accept a matching collision only once: verify both fruits are eligible, mark both as merging immediately, and only then schedule removal, create the successor, and apply score or effects. This makes the merge a single transaction instead of a side effect that can run again when another collision callback arrives.

Why a single collision can produce duplicate merges

Physics engines may report contact through multiple callbacks or callback paths. If the game waits until deferred cleanup to mark a fruit as consumed, another callback can claim the same fruit first. The results can include two successor fruits, duplicate score or sound, and old fruit bodies that remain active after their artwork disappears.

As an Amazon Associate I earn from qualifying purchases.

The specific event name and callback behavior depend on the engine. A Matter.js teaching example uses collisionStart; a Defold forum discussion focuses on collision groups and masks; and a melonJS adapter note describes a legacy dynamic-pair behavior that can call back twice per frame. That melonJS behavior is not a general rule for Matter.js or other engines.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use one guarded merge transaction

  1. Validate the pair. Reject contacts that are not between fruit, whose types do not match, or whose bodies are already merging or consumed. For example, the cited Matter.js tutorial checks the fruit label and matching fruit index.
  2. Claim both bodies synchronously. Set each source body’s merging or consumed state before queuing animation, removal, spawning, score, or sound. The second callback must see that claim and exit. The Matter.js example sets both bodyA.merging and bodyB.merging before scheduling removal and creating the next fruit.
  3. Capture the merge data. Save the successor type and spawn position from the accepted pair before destroying or mutating either body. This also avoids deferred work relying on values that may change.
  4. Defer world changes only when the engine requires it. Some physics APIs require body additions or removals at a safe point. Use the timing rules for your engine; do not copy another engine’s delay as if it were universal.
  5. Retire both sources completely. Remove their physics bodies and game-side references, including entries in any parallel entity or fruit collections, then add exactly one successor.
  6. Commit effects once. Award score and trigger sound or visual effects from the accepted merge event, not from separate callbacks. Keep the consumed state in force until the old bodies can no longer receive gameplay callbacks.

A useful invariant is: one accepted pair produces one successor and one set of side effects, while each source becomes unavailable as soon as the pair is accepted.

#1 Best Overall
Who is It, Fruit Guessing Game, Classic Family Board Games, Fun Puzzle Game for Travel, Party Favors
  • Simple Rule: Both the red and blue teams set up puzzles and take turns asking "yes/no" questions to narrow down the scope. The person who guesses the opponent's selected pattern first will score points. The game uses a sliding scoreboard to record match points, and the first to score 5 points wins. The intense and stimulating competitive process greatly exercises your logical thinking and reasoning analysis abilities.
  • Enhanced Learning: Guessing fruit game is a set of scientific intellectual development tools. Players need to close patterns on the game board that do not meet the criteria based on the opponent's answer, and advance the answer layer by layer through elimination and induction methods. In a gradual process, effectively cultivate your hands-on and cognitive abilities, observation skills, and problem-solving skills.
  • Easy Installation: Who is it set includes one red and one blue game disk, one instruction manual, two sets of small cards (48 cards in total), and two sets of large cards (48 cards in total). Align the card frame with the chassis cylinder and press lightly to fasten it. The digital scoreboard is easy to install and does not require tools. It can be played immediately after opening the box, making it convenient for you to operate independently.
  • Multi Functional Fun: Guessing board game, players exercise problem-solving, logical reasoning, and observation by analyzing responses and asking questions. Blending education with fun, the game develops mental agility, decision-making, and strategic thinking, providing an interactive experience that enhances critical skills while keeping players entertained.
  • Ideal Choice: Fun puzzle game compact and durable board game is perfect for any occasion, such as family gaming nights, weekend gatherings, travel and entertainment, and many other scenes. It is easy to package and install, making it perfect for giving to family parties, game nights, birthdays, Easter, Halloween, Christmas or New Year celebrations.

Choose guards that match the callback problem

Guard What it prevents Tradeoff
Per-body merging or consumed state A fruit being claimed again while cleanup is pending, including by a different simultaneous pair. Set it before asynchronous work begins, and do not clear it while the source can still receive gameplay callbacks. This pattern is shown in the Matter.js tutorial: HinaTech Games’ Matter.js fruit-merge tutorial.
Canonical pair key using stable entity IDs The same pair being processed through multiple callback paths. It does not stop one fruit from being claimed by two different pairs, so retain per-body consumed state as well. This is an implementation option for the repeated-callback risk, not a benchmarked alternative.
Callback-side or orientation filter Repeated handling in an engine with documented two-sided or revisited-pair callbacks. Engine-specific; an incorrect orientation assumption can suppress a legitimate event. A legacy melonJS adapter note describes such a case and distinguishes it from Matter.js: melonJS issue 963.

Choose based on the engine’s callback contract, whether more than one handler can process a pair, protection against multi-pair claims, and how clearly cleanup is represented. No one guard is established as universally fastest or best.

Represent fruit identity reliably

A collision filter can establish whether an object belongs to a fruit category, but the game still needs a reliable way to compare fruit types. In Defold, the cited discussion describes using collision groups and masks or checking the reported other group; the merge logic should distinguish “is a fruit” from “is the same fruit type.” See the Defold fruit-merging discussion for that engine-specific context.

Rank #2
Sale
Fruit Memory Matching Game, 54 Piece Family Board Game
  • Memory Building Play: This memory game turns colorful fruit pictures into a fun matching game that helps kids practice visual recognition, concentration
  • Easy To Learn: Players take turns flipping 2 pieces and keep the pair when the fruit pictures match, making this board game simple for kids and engaging for adults
  • 54 Piece Fruit Theme: Bright fruit designs add color and variety to every round while this educational toy encourages visual recognition, memory recall, focus, and fine motor skills
  • Play Together Anywhere: A versatile kids board game for family game nights, playdates, kindergarten activities, classrooms, gatherings, and travel entertainment without screens
  • Learning Gift For Kids: This educational toy combines puzzle games, brain games, and social play in one engaging challenge, making it a thoughtful choice for birthdays and holidays

Diagnose the duplicate before changing physics settings

Log stable IDs for both bodies, their type or index, the callback phase, and each body’s merge state before mutation. Also count accepted merge commits, successor bodies created, and source bodies removed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • If one contact produces several callbacks but only one accepted commit, the guard is working.
  • If one commit creates multiple successors, check whether more than one handler invokes creation or whether deferred callbacks captured mutable data.
  • If fruit artwork vanishes but contacts continue, check that the physics bodies left the world and that game-side collections no longer retain the consumed entities.

These checks distinguish duplicate event delivery from duplicate transaction execution and from incomplete cleanup; they do not require changing collision response or tuning the physics simulation.

Rank #3
Fruit Matching Puzzle Game for Kids & Adults, Pattern Block Building Cubes
  • 10 FRUIT MATCHING BLOCKS – Includes 10 colorful fruit pattern blocks with fun fruit designs for hands-on matching play. Kids can observe the challenge cards, find the corresponding fruit pieces, and arrange the blocks to complete different patterns in this engaging fruit matching game.
  • PATTERN BLOCK PUZZLE CHALLENGE – Use the 10 fruit blocks to recreate different combinations shown on the challenge cards. This pattern block puzzle game combines visual matching, block building, and quick thinking for a simple but engaging tabletop challenge.
  • FAMILY GAME FOR KIDS & ADULTS – A fun choice among family games for kids and adults, bringing children, parents, siblings, and friends together for friendly competition. Great for family game night, playdates, parties, and everyday indoor play.
  • MATCH, BUILD & SOLVE – Look at the card, identify the fruit patterns, then arrange the 10 fruit blocks into the correct layout. This hands-on matching game encourages observation, pattern recognition, and simple problem solving while keeping each round interactive and easy to understand.
  • FUN BOARD GAME FOR AGES 3+ – Designed for kids ages 3 and up, this compact family board game is suitable for home, travel, parties, and vacations. A colorful addition to kids board games, puzzle games, board games for kids, and family tabletop activities.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Engine-specific details matter

The Matter.js example filters by label and matching fruit index, marks both bodies as merging, then schedules removal and successor creation. Defold’s discussion illustrates collision-group filtering. The melonJS adapter note concerns a distinct legacy callback behavior, so an orientation workaround from that context should not be applied blindly elsewhere. Confirm the event contract and safe mutation timing in the documentation for the engine and version your game actually uses.

Quick Recap

SaleBestseller No. 2
Fruit Memory Matching Game, 54 Piece Family Board Game
Fruit Memory Matching Game, 54 Piece Family Board Game
Reminder: Only stickers and accessories are provided, you need to DIY the whole process
$8.99
Bestseller No. 4
Fruit Drops 3 - Match three puzzle
Fruit Drops 3 - Match three puzzle
Multifaceted Fruit themed match three adventure; Unrivaled level design, Right amount of level challenges for all ages from 5 to 99.
$1.99
Bestseller No. 5
Fruit Drops
Fruit Drops
Addictive match three puzzle game.; Multiple objectives,challenges and obstacles; 15 Fruity power up combinations!
$1.99
Best Value
Fruit Drops
  • Addictive match three puzzle game.
  • Multiple objectives,challenges and obstacles
  • 15 Fruity power up combinations!
  • Each level presents you with unique Objectives and Challenges.
  • Obstacles mixed with unique level board shapes will keep you swapping and swiping fruits for more!
Rank #4
Fruit Drops 3 - Match three puzzle
  • Multifaceted Fruit themed match three adventure
  • Unrivaled level design, Right amount of level challenges for all ages from 5 to 99.
  • Create powerful chained power up cascades to level up!
  • No in-app purchase, one time payment for the whole gaming experience.
  • Hints/Music/Banners can be disabled.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.