~cmiller/+junk/kenvandine-maze-plus-level-compiler

« back to all changes in this revision

Viewing changes to Finish.qml

  • Committer: Ken VanDine
  • Date: 2014-10-22 21:53:14 UTC
  • Revision ID: ken.vandine@canonical.com-20141022215314-op96fhzc9epfs2qh
init

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.2
 
2
import Bacon2D 1.0
 
3
 
 
4
Entity {
 
5
    id: finish
 
6
    bodyType: Entity.Static
 
7
 
 
8
    fixtures: Box {
 
9
        id: box
 
10
        anchors.fill: parent
 
11
        sensor: true
 
12
 
 
13
        onContactChanged: {
 
14
            if (other.parent != ball || ball.state == "gone")
 
15
                return;
 
16
 
 
17
            if (ball.x < finish.x + finish.width &&
 
18
                    ball.x >= finish.x &&
 
19
                    ball.y < finish.y + finish.height &&
 
20
                    ball.y >= finish.y) {
 
21
                ball.disappearTo(ball.parent.mapFromItem(finish,
 
22
                                                         box.width / 2,
 
23
                                                         box.height / 2))
 
24
                world.won()
 
25
            }
 
26
        }
 
27
    }
 
28
 
 
29
    Image {
 
30
        id: image
 
31
        anchors.fill: parent
 
32
        source: "finish.png"
 
33
        fillMode: Image.Tile
 
34
        clip: true
 
35
    }
 
36
}