Hi guys,
With the transition to Graphics 2.0, many things have changed, and many of us have huge projects which needs updating. This can be a daunting task, but a wrapper can save us a lot of time! We could use the compatibility mode, but then it was not recommended to use any Graphics 2.0 features. So I believe with a wrapper we can make the best of both worlds.
So together, lets make a Graphics2.0 wrapper!
To kick things off, I’ve wrapped **displayObject:setFillColor() **when using display.newImage() and display.newImageRect(). Next It would be awesome with a wrapper for displayObject:setReferencePoint() to work with the new anchor point system.
-- Wrapper functions ------------------------------------------------ local g2wrapper = {} -- setFillColor wrapper function g2wrapper:setFillColor( a, b, c, d ) if a then a = a/255 end if b then b = b/255 end if c then c = c/255 end if d then d = d/255 end -- Overload handling if a and b and c and d then -- R G B A self:\_setFillColor( a, b, c, d ) elseif a and b and c then -- R G B self:\_setFillColor( a, b, c ) elseif a and b then -- Luminence Apha self:\_setFillColor( a, b ) elseif a then -- Luminence self:\_setFillColor( a ) end end -- Modify objects to use wrapper ------------------------------------------------ -- Modify display object returned by newImageRect display.\_newImageRect = display.newImageRect display.newImageRect = function( arg1, arg2, arg3, arg4, arg5 ) local obj = display.\_newImageRect( arg1, arg2, arg3, arg4, arg5 ) obj.\_setFillColor = obj.setFillColor obj.setFillColor = g2wrapper.setFillColor return obj end -- Modify display object returned by newImageRect display.\_newImage = display.newImage display.newImage = function( arg1, arg2, arg3, arg4, arg5, arg6 ) local obj = display.\_newImage( arg1, arg2, arg3, arg4, arg5, arg6 ) obj.\_setFillColor = obj.setFillColor obj.setFillColor = g2wrapper.setFillColor return obj end
Should we setup a github for this? As it grows the forum might not be ideal to keep track of this.
Cheers,
Christer Eckermann