[SOLVED] How do I partially mask a sprite?

0 favourites
  • 6 posts
From the Asset Store
Basic template for drawing game with masks and easy customization
  • Hi all, I'm trying to figure out how to do the below:

    Step 1: Player clicks and holds to place a slug.

    Step 2 & 3: Player drags back and forth to determine the length of the slug, releases mouse click to make their selection.

    Prototype is here: https://pyremonk.itch.io/mushroomhigh

    I'm thinking of doing this with two sprite assets. One for the head of the slug and another with the body that is as long as the max length possible. Player would click, the head would get placed and the body would only show the tail end of the body asset and then sort of slide out from the head sprite. Is there a way to do spawn the body sprite and mask it under the head sprite even though it is long than the head?

    Right now I have this implemented with a single square sprite, but if I were to make a single sprite for the slug, it will look weird when I shorten and lengthen the sprite. I'm trying to come up with a way to make this pretty.

    Any ideas?

  • So, there are two main possibilities:

    one is with using a 9patch.

    one is with using three sprites.

    both have advantages and disadvantages.

    9patch:

    • just one object to manage, better performance with more objects
    • can't rotate, only dragging in one direction

    three sprites:

    • able to rotate
    • three sprites, worse performance with many objects

    Here is a .capx demonstrating both possibilities:

    Download .capx

    (enable or disable the group you wanna test. only have one group at a time enabled!!)

  • Awesome! Thank you!

    I think this will do the trick for what I'm looking for. I'm not sure which one to go with yet, but both work.

    When I've play tested with two-players and P2 tries to place a slug while P1 is jumping and moving the camera/view, the mouse follows the camera and creates a wonky experience for P2 by elongating and changing the angle of the slug they are currently trying to place. This makes trying to save P1 or "catch" them with a slug very difficult. If I use the 9-patch and stick with horizontal placement, it will look good and "fix" that issue. I'll have to test it out. I'm not sure how much I'll miss the ability to rotate.

  • I tested with the 9-patch and it doesn't quite feel right. I think I'll go with the 3 image technique. It still allows for some weirdness when stretching the body sprite, but I'll settle for it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I guess by "weirdness when stretching the body sprite", you are referring to blurry edges when scaling?

    If that's the case, there is a solution to that: replace the body sprite with a tiled background. That's all.

  • Yes! That works even better. Thanks again!

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