[SOLVED] How do I partially mask a sprite?

Get help using Construct 2

Post » Mon Nov 28, 2016 10:12 pm

Hi all, I'm trying to figure out how to do the below:

Image

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?
Last edited by pyremonk on Wed Nov 30, 2016 7:33 am, edited 1 time in total.
B
27
S
11
G
4
Posts: 14
Reputation: 3,936

Post » Tue Nov 29, 2016 12:26 am

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!!)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Tue Nov 29, 2016 4:13 am

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.
B
27
S
11
G
4
Posts: 14
Reputation: 3,936

Post » Tue Nov 29, 2016 5:00 am

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. :)
B
27
S
11
G
4
Posts: 14
Reputation: 3,936

Post » Tue Nov 29, 2016 4:36 pm

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.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Wed Nov 30, 2016 7:34 am

Yes! That works even better. Thanks again!
B
27
S
11
G
4
Posts: 14
Reputation: 3,936


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests