guys see the below code what i am doing wrong or why it is not going to 0,0 position
function drawRect(left,top,width,height)
local shape = Shape.new()
shape:setFillStyle(Shape.SOLID, 0xffffff, 0.5)
shape:beginPath()
shape:moveTo(left,top)
shape:lineTo(left + width, top)
shape:lineTo(left + width, top+height)
shape:lineTo(left, top+height)
shape:closePath()
shape:endPath()
return shape
end
local myRect = drawRect(100,0,50,80)
myRect:setColorTransform(0,0,0,1)
stage:addChild(myRect)
myRect:setPosition(0,0) -- this is a issue need to move it to 0,0 point |
same for circle shape also
function drawArc(xc,yc,xradius,yradius,startAngle,endAngle,isFill)
if yradius == nil then
yradius = xradius
end
if startAngle == nil then
startAngle = 0
end
if endAngle == nil then
endAngle = 360
end
if isFill == nil then
isFill = true
end
local shape = Shape.new()
if isFill then
shape:setFillStyle(Shape.SOLID, 0xffffff, 0.5)
else
shape:setLineStyle(3, 0x000000)
end
shape:beginPath()
for i=startAngle,endAngle do
if i==1 then
shape:moveTo(xc + math.sin(math.rad(i)) * xradius,yc + math.cos(math.rad(i)) * yradius)
else
shape:lineTo(xc + math.sin(math.rad(i)) * xradius,yc + math.cos(math.rad(i)) * yradius)
end
end
if isFill then
shape:closePath()
end
shape:endPath()
return shape
end
local myCircle = drawArc(150,55,50)
myCircle:setPosition(0,0) -- same issue cant move it
myCircle:setColorTransform(0,1,0,1)
stage:addChild(myCircle) |
thnx
Comments
thnx
</pre>
Likes: jdbc
Most probably you want to create your rectangle as:
Likes: atilim, ndoss, MoKaLux