30
30
if self.x ~= mirrorX then
31
31
if not self.xMirror then
32
--print('creating mirror: X='..xMirrorX..' Y='..xMirrorY)
32
--print('creating mirror: X='..mirrorX..' Y='..mirrorY)
34
34
self.xMirror = Mirror:new{ of = self, image = self.image }
35
35
the.mirrors:add(self.xMirror)
40
40
self.xMirror.rotation = self.rotation
41
41
self.xMirror.scale = self.scale
42
42
elseif self.xMirror then
43
if self.type == 'bullet' then
44
--print('pruning bullet')
43
46
the.mirrors:remove(self.xMirror)
47
self.xMirror.of = nil -- break circular reference
48
52
if self.y ~= mirrorY then
49
53
if not self.yMirror then
50
--print('creating mirror: X='..yMirrorX..' Y='..yMirrorY)
54
--print('creating mirror: X='..mirrorX..' Y='..mirrorY)
52
56
self.yMirror = Mirror:new{ of = self, image = self.image }
53
57
the.mirrors:add(self.yMirror)
58
62
self.yMirror.rotation = self.rotation
59
63
self.yMirror.scale = self.scale
60
64
elseif self.yMirror then
65
if self.type == 'bullet' then
66
--print('pruning bullet')
61
68
the.mirrors:remove(self.yMirror)
69
self.yMirror.of = nil -- break circular reference
66
74
if self.x ~= mirrorX and self.y ~= mirrorY then
67
75
if not self.xyMirror then
68
--print('creating mirror: X='..xyMirrorX..' Y='..xyMirrorY)
76
--print('creating mirror: X='..mirrorX..' Y='..mirrorY)
70
78
self.xyMirror = Mirror:new{ of = self, image = self.image }
71
79
the.mirrors:add(self.xyMirror)
76
84
self.xyMirror.rotation = self.rotation
77
85
self.xyMirror.scale = self.scale
78
86
elseif self.xyMirror then
87
if self.type == 'bullet' then
88
--print('pruning bullet')
79
90
the.mirrors:remove(self.xyMirror)
91
self.xyMirror.of = nil -- break circular reference
80
92
self.xyMirror = nil
84
96
onRemove = function(self)
85
97
if self.xMirror then
98
if self.type == 'bullet' then
99
--print('removing bullet, so removing mirror')
86
101
the.mirrors:remove(self.xMirror)
102
self.xMirror.of = nil -- break circular reference
89
106
if self.yMirror then
107
if self.type == 'bullet' then
108
--print('removing bullet, so removing mirror')
90
110
the.mirrors:remove(self.yMirror)
111
self.yMirror.of = nil -- break circular reference
93
115
if self.xyMirror then
116
if self.type == 'bullet' then
117
--print('removing bullet, so removing mirror')
94
119
the.mirrors:remove(self.xyMirror)
120
self.xyMirror.of = nil -- break circular reference
97
124
update = function (self, elapsed)
98
125
Tile.update(self, elapsed)
b'\\ No newline at end of file'