0 Favourites

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

  • 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. <img src="smileys/smiley11.gif" border="0" align="middle" />

    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. <img src="smileys/smiley5.gif" border="0" align="middle" />

  • 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)

  • 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. <img src="smileys/smiley36.gif" border="0" align="middle" />

    Seems to be working now, I'll get started on makin' magic!

  • 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 <img src="smileys/smiley4.gif" border="0" align="middle">

  • 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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • My edit might've been a bit too sneaky before. <img src="smileys/smiley17.gif" border="0" align="middle" />

    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.

  • Is there a way to know in what effect is an object during runtime ?

    A condition of an event ?

  • 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 <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 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

  • smitchell you're right that would work!

    thx

  • No probs <img src="smileys/smiley4.gif" border="0" align="middle" />

  • r0j0 posted something like that not long ago

    r0j0_scrolling.capx

    I just changed the color of the borders to black to fake text disparition

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