How do I cut a hole in a sprite using the drawing canvas object?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have roughly 35 sprites on the screen, all on their own layer. When the player clicks on one of these sprites I want to punch a hole in it.

    I found an example from dop2000 and tried to adapt it, but the sprite clicked on either turns black, or it cuts out a sprite shaped hole in everything else in the background.

    Note: My canvas object is on the same layer as my sprites. I also set the "Force own texture" to true for this layer.

    Any suggestions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The object that "cuts a hole" into the drawing canvas, must have the blend mode "destination out" set on it.

    When you set this, it won't always look how you're expecting in layout view, but once you paste, it will do exactly what you hope.

    If you still need a visual sprite to show the area you're about to make a hole, then I'd suggest 2 sprites, one with destination out, one without. (you could do 1 sprite and "set blend mode to destination out, paste, set blend mode to Normal, but it will change it's appearance during the paste).

    If you used many layers with Force Own Texture, just for this hole system, you may not need all of this - even 1 layer, without Force Texture, will still punch a hole when you paste a Destination Out sprite.

    Hope this helps!

  • Thanks for the reply, Jase00!

    I was trying to follow dop2000's example described here:

    construct.net/en/forum/construct-3/how-do-i-8/punch-hole-sprite-reveal-layer-156127

    I modified it to work on just the sprite being clicked on:

    This works... but those same events don't work in my game. I tried to match the sprite and layer details, but with no luck.

    One difference is the way I had to use containers. My game uses spr_card and fam_cards (with spr_card as the only member), and all card references use fam_cards. Unfortunately, I apparently can't use a family in a container... so I had to add spr_card instead. Not sure if that messed anything up or not.

  • Not sure what I'm doing wrong but I just can't get this to work.

    Here's basically what I'm trying to do. If anyone sees an issue with any of these steps, please let me know.

    - Player clicks on sprite

    - Make sprite invisible

    - Create instance of sprite on "Effects" layer (texture draw = true)

    - Make new instance invisible

    - Copy new instance to canvas (also on "Effects" layer)

    - Wait for events (give time for draw to happen)

    - Set canvas blend mode to Destination Out

    - Paste hole sprite to canvas

    When I do this my sprite image turns black. Any ideas?

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