So far I am able to create a rect instance and draw it on the screen.
local platform
local function initialize()
platform = pd.geometry.rect.new(100,100,100,10)
end
initialize()
function pd.update()
gfx.clear()
gfx.fillRect(platform)
gfx.sprite.update()
end
Is it possible to rotate a rectangle using the SDK?
Probably the easiest way is to convert the rect to a polygon and use affine transform. Something like:
local platformPolygon
local function initialize()
platformPolygon = pd.geometry.rect.new(100,100,100,10):toPolygon()
end
initialize()
function pd.update()
gfx.clear()
local transform = pd.geometry.affineTransform.new()
transform:rotate(angle, centerOfRotation)
local rotatedPlatform = transform:transformedPolygon(platformPolygon)
gfx.fillPolygon(rotatedPlatform)
end
(this assumes you want it drawn at a different angle every frame. Also you could probably optimize it by storing the transform and updating it instead of creating a new transform each frame)