Transition fillColor with corona sdk graphics 2.0

Hey guys I'm looking for a way I can transition rect fill color with graphics 2.0 corona sdk. So basically start blue and then gradually change red over 5 seconds and then red to yellow etc...

Right now I'm using Atoko's color transition wrapper to transition between colors and was looking for an official way to do this with coronas own API.

Can this be done?

http://developer.coronalabs.com/code/color-transition-wrapper

Cheers,


The main issue is that fill color is not an attribute, it is set via a function call. So there is no official way. You could use transition.to , which Atoko's lib does. That lib just provides a convenience function that creates an object that has an "attribute" which, when set, calls the setFillColor on original object.

The other method is to use a timer, as done in http://developer.coronalabs.com/code/easy-setfillcolor-transition. The code is simpler to understand because there are no metatables overriding the __newindex , but the end result is same.

You should probably use whichever you are most comfortable with, unless you find that one of the two has a limitation that is not obvious on first inspection.


I hope this one will help you:

http://docs.coronalabs.com/guide/graphics/effects.html

链接地址: http://www.djcxy.com/p/25896.html

上一篇: 在电晕sdk的Tableview

下一篇: 用corona sdk graphics 2.0转换fillColor