-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transfer.lua
49 lines (42 loc) · 951 Bytes
/
Transfer.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- transfer class
Transfer = {}
-- constructor
function Transfer:new(x, y, width, height, destination, newx, newy)
local object = {
x = x,
y = y,
width = width or 32,
height = height or 32,
destination = destination,
newx = newx,
newy = newy,
}
setmetatable(object, { __index = Transfer })
return object
end
-- update transfer
function Transfer:update(dt)
end
-- keypressed callback
function Transfer:keypressed(key)
end
-- check a collision
function Transfer:iscollision(dt)
if (herorat.x > self.x and herorat.x < self.x + self.width and herorat.y > self.y and herorat.y < self.y + self.height) then
return true
else
return false
end
end
-- what to do on a collision
function Transfer:oncollision(dt)
map = loader.load(self.destination..".tmx")
layer = map("Objects")
layer:toCustomLayer(convertobject)
herorat.x = self.newx
herorat.y = self.newy
end
-- draw transfer
function Transfer:draw()
-- nothing to draw
end