コンテンツにスキップ

How do you manage collectables/coins in platformers?

このコンテンツはまだ日本語訳がありません。

💡 Struggling with collectables and collision detection? Need help with sprite management? 🚀 Get Help Now

PA

PlatformDev_Alex

Posted on July 26, 2025 • Intermediate

🎮 Need help with collectables management in platformers

Hey everyone! I’m working on a platformer game and I’m having trouble with managing collectables and coins effectively. Currently I’m using basic color recognition but I feel like there might be a better approach.

Here’s my current project: https://scratch.mit.edu/projects/1201567682/

Right now I’m trying to detect yellow coins (color #FFFF00) using color touching blocks in the player sprite, but I’m wondering if there’s a more efficient way to handle this?

Any suggestions would be really appreciated! 🙏

CS

CloneSpecialist_Maya

Replied 5 hours later • ⭐ Best Answer

Great question @PlatformDev_Alex! You’re absolutely right that there’s a much better approach than color detection. Using sprite clones for collectables is the way to go! 🎯

🔄 Collectables System Flow

Here’s how a proper collectables system should work:

flowchart TD A[🚀 Game Start] --> B[Create Coin Clones] B --> C[Position Coins in Level] C --> D[🎮 Game Loop] D --> E{Player Touches Coin?} E -->|Yes| F[💰 Collect Coin] E -->|No| D F --> G[Play Collection Sound] G --> H[Add to Score/Inventory] H --> I[Delete This Clone] I --> J{More Coins Left?} J -->|Yes| D J -->|No| K[🏆 Level Complete] style A fill:#e1f5fe style F fill:#e8f5e8 style K fill:#fce4ec style I fill:#fff3e0

🪙 Step 1: Create the Coin Sprite

First, create a separate coin sprite (don’t use color detection in the player). Here’s the coin sprite code:

    when flag clicked
hide
forever
create clone of [myself v]
wait [0.1] seconds
end
  

🎯 Step 2: Clone Positioning System

For the coin clones, use this positioning system:

    when I start as a clone
go to x: (pick random [-200] to [200]) y: (pick random [-100] to [100])
show
forever
if <touching [Player v]?> then
change [Score v] by [10]
play sound [coin collect v]
delete this clone
end
end
  

🎮 Step 3: Advanced Coin Management

For better control, use lists to store coin positions:

    // In the main sprite (like Stage)
when flag clicked
delete all of [Coin X v]
delete all of [Coin Y v]

// Add coin positions to lists
add [100] to [Coin X v]
add [50] to [Coin Y v]
add [-150] to [Coin X v]
add [80] to [Coin Y v]

// Create coins from list data
repeat (length of [Coin X v])
broadcast [create coin v]
end
  

📍 Step 4: Precise Coin Placement

In the coin sprite, use the list data:

    when I receive [create coin v]
change [coin index v] by [1]
go to x: (item (coin index) of [Coin X v]) y: (item (coin index) of [Coin Y v])
create clone of [myself v]
  

✨ Step 5: Enhanced Collection Effects

Make coin collection more satisfying:

    when I start as a clone
show
forever
if <touching [Player v]?> then
// Collection animation
repeat [10]
change y by [5]
change size by [-5]
end

// Update game state
change [Score v] by [10]
change [Coins Collected v] by [1]
play sound [coin collect v]

// Particle effect (optional)
broadcast [coin collected v]

delete this clone
end
end
  

This approach is much more efficient and flexible than color detection! You can easily add different types of collectables, manage their positions, and create cool effects. 🌟

PA

PlatformDev_Alex

Replied 2 hours later

@CloneSpecialist_Maya This is exactly what I needed! Thank you so much! 🎉

The clone approach makes so much more sense than trying to detect colors. I’m implementing this right now and it’s working perfectly!

VB

Vibelf_Community

Pinned Message • Moderator

🚀 Ready to Master Game Mechanics?

Excellent discussion on collectables management! For those looking to implement even more advanced systems, our community can help you create:

  • 🎯 Multi-type collectables systems
  • 💎 Rare item spawn mechanics
  • 🗺️ Level-based coin placement
  • 🏪 Shop integration systems

📚 Related Topics

Need personalized help with your platformer game? Connect with expert tutors in the Vibelf app for one-on-one guidance!