/ld26

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

« back to all changes in this revision

Viewing changes to transition.lua

  • Committer: Josh C
  • Date: 2013-04-27 18:39:03 UTC
  • Revision ID: josh@9ix.org-20130427183903-3uc24myj115nckj0
scale movement with player size

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Transition = Group:extend {
2
 
   visible = false,
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
 
                           --print("Sending to "..t.target)
14
 
 
15
 
                           the.player.active = false
16
 
                           the.app.view:fade({0,0,0}):andThen(function()
17
 
                              the.app.view = GameView:new{level = t.target}
18
 
 
19
 
                              if t.targetX or t.targetY then
20
 
                                 the.player.x = t.targetX
21
 
                                 the.player.y = t.targetY
22
 
                              end
23
 
                           end)
24
 
                        else
25
 
                           print("Colliding with: "..other)
26
 
                        end
27
 
                     end
28
 
                  }
29
 
      self:add(box)
30
 
      self:add(Text:new{x = self.x, y = self.y,
31
 
                        text = "T"
32
 
                     })
33
 
     
34
 
      -- make sure collision doesn't think group is a sprite
35
 
      self.x, self.y, self.width, self.height = nil, nil, nil, nil
36
 
   end,
37
 
   onUpdate = function(self, dt)
38
 
                 self.visible = DEBUG and the.console.visible
39
 
              end
40
 
}