I tried:
Code: Select all
local rotate = function(self, angle)
-- TODO
print("It worked.")
end
local originalNewTransform = love.math.newTransform
function love.math.newTransform(...)
local new = originalNewTransform(...)
new.rotate = rotate
return new
end
local transform = love.math.newTransform()
transform:rotate(math.pi / 2)
Code: Select all
local rotate = function(self, angle)
-- TODO
print("It worked.")
end
local transformMetatable = {
__index = function(table, key)
return key == "rotate" and rotate or rawget(table, "key")
end
}
local originalNewTransform = love.math.newTransform
function love.math.newTransform(...)
return setmetatable(originalNewTransform(...), transformMetatable)
end
local transform = love.math.newTransform()
transform:rotate(math.pi / 2)
Help! What do I do? I thought maybe I could use FFI to replace the Transform class from LÖVE with a subclass that has its rotate method replaced (I could make my sine and cosine in C) but A: ffi.c.love doesn't exist and B: LÖVE is C++ and already compiled, so... yeah! Completely stumped.
Any help is appreciated! Thank you.