/traderous

To get this branch, use:
bzr branch http://9ix.org/bzr/traderous

« back to all changes in this revision

Viewing changes to wrap_tile.lua

  • Committer: Josh C
  • Date: 2013-05-13 21:31:23 UTC
  • Revision ID: josh@9ix.org-20130513213123-n21tkmyb2u7xcjtz
monkey patch group to add onRemove hook.  remove mirrors on remove.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
                  if not self.xMirror then
32
32
                     --print('creating mirror: X='..xMirrorX..' Y='..xMirrorY)
33
33
 
34
 
                     self.xMirror = Mirror:new{ of = self, image = self.image }
35
 
                     the.mirrors:add(self.xMirror)
 
34
                     self.xMirror = Tile:new{ image = self.image }
 
35
                     the.app.view:add(self.xMirror)
36
36
                  end
37
37
 
38
38
                  self.xMirror.x = mirrorX
39
39
                  self.xMirror.y = self.y
40
40
                  self.xMirror.rotation = self.rotation
41
 
                  self.xMirror.scale = self.scale
42
41
               elseif self.xMirror then
43
 
                  the.mirrors:remove(self.xMirror)
 
42
                  the.app.view:remove(self.xMirror)
44
43
                  self.xMirror = nil
45
44
                  -- die?
46
45
               end
49
48
                  if not self.yMirror then
50
49
                     --print('creating mirror: X='..yMirrorX..' Y='..yMirrorY)
51
50
 
52
 
                     self.yMirror = Mirror:new{ of = self, image = self.image }
53
 
                     the.mirrors:add(self.yMirror)
 
51
                     self.yMirror = Tile:new{ image = self.image }
 
52
                     the.app.view:add(self.yMirror)
54
53
                  end
55
54
 
56
55
                  self.yMirror.x = self.x
57
56
                  self.yMirror.y = mirrorY
58
57
                  self.yMirror.rotation = self.rotation
59
 
                  self.yMirror.scale = self.scale
60
58
               elseif self.yMirror then
61
 
                  the.mirrors:remove(self.yMirror)
 
59
                  the.app.view:remove(self.yMirror)
62
60
                  self.yMirror = nil
63
61
                  -- die?
64
62
               end
67
65
                  if not self.xyMirror then
68
66
                     --print('creating mirror: X='..xyMirrorX..' Y='..xyMirrorY)
69
67
 
70
 
                     self.xyMirror = Mirror:new{ of = self, image = self.image }
71
 
                     the.mirrors:add(self.xyMirror)
 
68
                     self.xyMirror = Tile:new{ image = self.image }
 
69
                     the.app.view:add(self.xyMirror)
72
70
                  end
73
71
 
74
72
                  self.xyMirror.x = mirrorX
75
73
                  self.xyMirror.y = mirrorY
76
74
                  self.xyMirror.rotation = self.rotation
77
 
                  self.xyMirror.scale = self.scale
78
75
               elseif self.xyMirror then
79
 
                  the.mirrors:remove(self.xyMirror)
 
76
                  the.app.view:remove(self.xyMirror)
80
77
                  self.xyMirror = nil
81
78
                  -- die?
82
79
               end
83
80
            end,
84
81
   onRemove = function(self)
85
82
                 if self.xMirror then
86
 
                    the.mirrors:remove(self.xMirror)
 
83
                    the.app.view:remove(self.xMirror)
87
84
                 end
88
85
 
89
86
                 if self.yMirror then
90
 
                    the.mirrors:remove(self.yMirror)
 
87
                    the.app.view:remove(self.yMirror)
91
88
                 end
92
89
 
93
90
                 if self.xyMirror then
94
 
                    the.mirrors:remove(self.xyMirror)
 
91
                    the.app.view:remove(self.xyMirror)
95
92
                 end
96
93
              end,
97
94
   update = function (self, elapsed)
99
96
 
100
97
               self:wrap()
101
98
               self:reflect()
 
99
 
 
100
               -- TODO: make sure mirrors are cleaned up when we are
 
101
               -- killed / removed from view
102
102
            end
103
103
}
 
 
b'\\ No newline at end of file'