Article Tutorials/Drawing Shapes (filled polygons)
Gideros Studio has a simple way of creating graphics in the way of Shapes.
To create a shape, you use draw it using line commands. Once created, the shape can be altered by rotating, changing transparency and scaling.
local myShape = Shape.new() myShape:setLineStyle(2) myShape:setFillStyle(Shape.SOLID, 0x9900ff) myShape:beginPath() myShape:moveTo(1,1) myShape:lineTo(100,1) myShape:lineTo(100,100) myShape:lineTo(1,100) myShape:lineTo(1,1) myShape:endPath() stage:addChild(myShape)
This will draw a purple rectangle.
Manipulating your shape:
myShape:setPosition(75,0) myShape:setRotation(45) myShape:setAlpha(0.5)
There are a few options with setFillStyle:
Shape.NONE = No fill
Shape.SOLID = Solid colour fill
Shape.TEXTURE = Fill your shape with the contents of a PNG for the texture
Also, there’s a few options for setLineStyle. The width, colour and alpha values.
setFillStyle(Shape.SOLID, 0x0000ff, 0.25)
This will set the shape as solid with a blue colour filling and a transparency of 0.25.
Note: This tutorial was written by Jason Oakley and was originally available here: http://bluebilby.com/2013/04/10/gideros-mobile-tutorial-displaying-graphics/.