/ld26

To get this branch, use:
bzr branch /bzr/ld26

« back to all changes in this revision

Viewing changes to transition.lua

  • Committer: Josh C
  • Date: 2013-04-28 01:21:46 UTC
  • Revision ID: josh@9ix.org-20130428012146-42c1hx6r1g7y1kgu
fade in

Show diffs side-by-side

added added

removed removed

1
1
Transition = Group:extend {
2
2
   visible = false,
3
3
   onNew = function(self)
4
 
              local t = self
5
 
              -- NOTE: X/Y will fail if you init Transition before Player!
6
 
              box = Fill:new{x = self.x, y = self.y,
7
 
                             height = self.height or the.player.height,
8
 
                             width = self.width or the.player.width,
9
 
                             fill = {0, 255, 0},
10
 
                             onCollide = function(self, other, xOl, yOl)
11
 
                                            -- (sanity check)
12
 
                                            if other == the.player then
13
 
                                               the.view:newLevel(t.target)
14
 
                                               if t.targetX or t.targetY then
15
 
                                                  the.player.x = t.targetX
16
 
                                                  the.player.y = t.targetY
17
 
                                               end
18
 
                                            else
19
 
                                               print("Colliding with: "..other)
20
 
                                            end
21
 
                                         end
22
 
                          }
23
 
              self:add(box)
24
 
              self:add(Text:new{x = self.x, y = self.y,
25
 
                                text = "T"
26
 
                             })
27
 
 
28
 
              -- make sure collision doesn't think group is a sprite
29
 
              self.x, self.y, self.width, self.height = nil, nil, nil, nil
30
 
           end,
 
4
      local t = self
 
5
      -- NOTE: X/Y will fail if you init Transition before Player!
 
6
      box = Fill:new{x = self.x, y = self.y,
 
7
                     height = self.height or the.player.height,
 
8
                     width = self.width or the.player.width,
 
9
                     fill = {0, 255, 0},
 
10
                     onCollide = function(self, other, xOl, yOl)
 
11
                        -- (sanity check)
 
12
                        if other == the.player then
 
13
                           --print("Sending to "..t.target)
 
14
 
 
15
                           the.app.view = GameView:new{level = t.target}
 
16
 
 
17
                           if t.targetX or t.targetY then
 
18
                              the.player.x = t.targetX
 
19
                              the.player.y = t.targetY
 
20
                           end
 
21
                        else
 
22
                           print("Colliding with: "..other)
 
23
                        end
 
24
                     end
 
25
                  }
 
26
      self:add(box)
 
27
      self:add(Text:new{x = self.x, y = self.y,
 
28
                        text = "T"
 
29
                     })
 
30
     
 
31
      -- make sure collision doesn't think group is a sprite
 
32
      self.x, self.y, self.width, self.height = nil, nil, nil, nil
 
33
   end,
31
34
   onUpdate = function(self, dt)
32
35
                 self.visible = DEBUG and the.console.visible
33
36
              end