Search code examples
imagemaskgame-makergml

how to use texture masks in game Maker?


First off I'm not totally sure if "texture masks" is the correct term to use here so If someone knows what it is then please let me know.

so the real question. I want to have an object in GameMaker: Studio which as it moves around it's texture changes depending on its position by pulling from a larger static image behind it. I've made a quick gif of what it might look like.

It can be found here

Another image that might help explain this is the "source-in" section of this image.this


Solution

  • This is a reply to the same question posted on the steam GML forum by MrDave:

    The feature you are looking for is draw_set_blend_mode(bm_subtract)

    Basically you will have to draw everything onto a surface and then using the code above you switch the draw mode to bm_subtract. What this will do is rather than drawing images to the screen it will remove them. So you now draw blocks over the background and this will remove that area. Then you can draw everything you just put on the surface onto the screen.

    (Remember to reset the draw mode and the surface target after. )

    Its hard to get your head around the first time, but actually it isn’t all that complex once you get used to it.