Nifty - Chaining effects

A couple more quick Nifty questions for you @void256 :slight_smile: Hopefully these will be the last for a while.



First:



Is it possible within the XML to chain effects. When one effect completes I want another one to automatically happen. For example a fade from #f to #0 that when it complete triggers a hide effect. I can’t find any way to do it at the moment which is a shame.



(I know you can to it by bouncing out to java to trigger the next effect - ideally I’d like to put all the layout logic inside the XML though so a single event can be fired from java and then the screen handles the rest. This means that different layouts (e.g. android vs PC) can all use identical code and just load different XML files).



Although a work around has just occurred to me - I could do a java method that accepts a string input and fires the custom key matching that input. That can then be called like so: [xml]onEndEffect="{CALL.triggerEffect(“test”)}"[/xml]. That should work right?



Second:



Is it possible to set the transparency on an image other than by adding an effect. I.e. I’d like to be able to do backgroundImage=“blah.jpg” alpha="#8" and render the image 50% transparent. Currently the only way I can see to do that is to apply a fade effect with neverStopRendering.

First:



This is currently not directly possible and requires some Java EndEffect callback. The onEndEffect way you’ve posted looks like it could work for this as well.



What I did in some of the more complicated demos is to use the “startDelay” and “length” attributes to make sure they start at the right time, e.g. set the “startDelay” attribute of the second effect to the “length” attribute of the first effect. The drawback is of course that when you need to change the timing you’ll need to change all effects.



Second:



This is currently not possible without effects. Sounds not to hard to add though. Maybe add a feature reuqest for this on the tracker?

First: Doh, why didn’t I think of that. It’s so obvious, although as you say it has the slight drawback of needing to keep the timers synched. It does have one advantage though - I can actual time the hide for slightly before the fade ends and make sure it doesn’t flash back to visible for a frame before disappearing.



Second: Will do.