Last active
November 29, 2017 05:16
-
-
Save qoh/a66f729d0e57b7e91201107adde864f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function checkjoint(world) | |
local joint = world:getJoints()[1] | |
print(string.format('type() = %s, getType() = %s', joint:type(), joint:getType())) | |
joint:setMotorEnabled(true) | |
end | |
function love.load() | |
local world = love.physics.newWorld() | |
local a = love.physics.newBody(world, 0, 0) | |
local b = love.physics.newBody(world, 0, 0) | |
love.physics.newRevoluteJoint(a, b, 0, 0) -- No reference kept | |
-- The object obtained from World:getJoints has the proper RevoluteJoint | |
-- metatable, and setMotorEnabled can be called | |
checkjoint(world) | |
-- Triggering manually for test, would happen eventually | |
collectgarbage() | |
-- Now that the joint has been garbage collected, it is recreated | |
-- incorrectly when retrieved again: | |
-- Its :type() is now 'Joint' (the base class, not the specific | |
-- RevoluteJoint), but its :getType() is still 'revolute', and | |
-- .setMotorEnabled no longer exists | |
checkjoint(world) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment