Dingping Lv wrote:
Do you have any ideas?
Well, I’m far from being a JS expert, but it sounds to me that what should be done is create a master, or rather, parent Color class and let it have all sorts of constructors (4b, 3b, 4f, 3f, etc - where the constructors with less parameters are just assuming opaciry at 100%), and use that parent class internally always for every method that needs information regarding colors, regardless of how the parameters were used for constructing the color object.
It smells like it may require quite a bit of refactoring ‘tho.
EDIT: another case in which having said color class would be usefull is when messing with “cc.drawingUtil.setDrawColor”, currently we only have “cc.drawingUtil.setDrawColor4B(r,g,b,a)” and “cc.drawingUtil.setDrawColor4F(r,g,b,a)”, but wouldn’t it be nice to have a “cc.drawingUtil.setDrawColor(color)” where ’color’ has been created with either c4f or c4b?