Is there a way to make part of a sprite disappear?

Get help using Construct 2

Post » Wed Jan 11, 2012 4:32 pm

For an effect in my game, I want this icon to gradually appear/disappear based on a certain value. And I don't mean opacity by that -- if the icon's a person, for example, his feet would appear, then legs, then torso, and so on. It's not just a plain rectangle, so the usual change width/height trick won't do me any good here.

I know I COULD make a bunch of sprites for each segment of it and toggle their visibility, but that's annoying to do and it won't look nearly as good as what I see in my mind, unless I literally made a sprite for every single line of pixels.

I was thinking one of the effects might be able to do it -- source out, maybe? -- but I barely know how to use them and the past hour of trying has yielded no luck.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Wed Jan 11, 2012 5:18 pm

I guess you're close to a solution. It should be indeed a matter of effects.

You can check out the "Sprite effects.capx" in the c2\examples folder of your installation.

I'd say you would have to spawn a "mask" sprite over your icon, and move it accordingly to the part of the icon you want to display (if only the feet must appear, position the mask so it covers all the icon except the feet. Tweaking the Y position here should work)
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Jan 11, 2012 5:52 pm

I'm pretty sure "source out" is the one I want to go with, but whenever I open up a new capx and put that effect on a sprite, it becomes a grey box during run-time. Literally all I'm doing is adding two sprites, giving one the effect, and that's it... Any idea what's wrong?

EDIT: Heh... apparently, the layer the sprites are on has to have "Force own texture" set to "Yes". Took an hour or two to catch that.

Seems to be working now, I'll get started on makin' magic!SullyTheStrange2012-01-11 18:01:26
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Wed Jan 11, 2012 6:09 pm

Notice how sprites with effects in the example capx are on a different layer than the background sprite.

In other cases, grey screen might indicate an error. Checking for errors in browsers is a good first step to follow.

I hope/think in this case it is just a matter of layers though
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Wed Jan 11, 2012 6:33 pm

the mask should be in destination-out and your layer should be set to force own texture = yes
Also, don't do it in the first layer. You'll dig a hole in the canvas and see the grey behind it :D
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Jan 12, 2012 3:51 am

My edit might've been a bit too sneaky before.

I figured it out, it was indeed a problem with the layer. And the screen itself wasn't turning grey, it was only the sprite with the effect on it... not sure why that would happen, but I guess it doesn't matter now!

Thanks guys.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Fri Jan 20, 2012 5:23 pm

Is there a way to know in what effect is an object during runtime ?
A condition of an event ?
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Fri Jan 20, 2012 5:31 pm

@guicole, im not sure if there is a native event for this, but you could surely have a work around.

For example if you had a instance var, or global for each effect.

And on the event where you set the sprites effect set the boolean to true then you would know
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Fri Jan 20, 2012 5:33 pm

Oh and... is there a way to apply an effect like that on Text ?

I want to have a menu with scrolling, so that the things are going to not appears outside a box.

The Effect for sprite works, but... how do we do it for the Text ?

I'm guessing that's dependant on the WebGL and Text above everything thing...
I know we can use text with the Canvas plugin... but... is there another way ?

thx
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Fri Jan 20, 2012 6:44 pm

@smitchell you're right that would work!
thx
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Next

Return to How do I....?

Who is online

Users browsing this forum: MrLOL64 and 21 guests