summaryrefslogtreecommitdiffhomepage
path: root/not/Platform.lua
blob: 29c74cf6738cf32d5419e68916e47021c1222c69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "not.PhysicalBody"

--- `Platform`
-- Static platform physical object with a sprite. `Players` can walk on it.
-- Collision category: [1]
Platform = PhysicalBody:extends()

-- Constructor of `Platform`
function Platform:new (animations, shape, x, y, world, imagePath)
	Platform.__super.new(self, x, y, world, imagePath)
	self:setAnimations(animations)
	-- Create table of shapes if single shape is passed.
	if type(shape[1]) == "number" then
		shape = {shape}
	end
	-- Add all shapes from as fixtures to body.
	for _,single in pairs(shape) do
		local fixture = self:addFixture(single)
		fixture:setCategory(1)
		fixture:setFriction(0.2)
	end
end

return Platform