Code: Select all
function love.load()
local vertices = {{0, 0}}
local segments = 40
for i=0, segments do
local angle = (i/segments)*math.pi*2
local x = math.cos(angle)
local y = math.sin(angle)
table.insert(vertices, {x, y})
end
img = love.graphics.newImage('pig.png')
mesh = love.graphics.newMesh(vertices, img, 'fan')
end
function love.draw()
local radius = 100
local mx, my = love.mouse.getPosition()
-- We created a unit-circle, so we can use the scale parameter for the radius directly.
love.graphics.draw(mesh, mx, my, 0, radius, radius)
end
The wiki article on meshes is confusing regarding which function template is available in 0.9.0. My only guess is that I'm sending the wrong arguments to the constructor. Can anyone see what is wrong with this code?main.lua:14: bad argument #8 to 'newMesh' (number expected, got nil)
Traceback
[C]: in function 'newMesh'
main.lua:14: in function 'load'
[C]: in function 'xpcall'