Updated examples to work with 1.1
[qml-box2d:qml-box2d-folibis.git] / examples / filtering / filtering.qml
1 import QtQuick 2.0
2 import Box2D 1.1
3
4 Item {
5     id: screen
6     width: 800
7     height: 600
8     World {
9         id: world;
10         anchors.fill: parent
11
12         Repeater {
13             model: 5
14             delegate: Body {
15                 x: index * 150 + 10;
16                 y: Math.random() * (screen.height / 3);
17                 width: 50;
18                 height: 50;
19                 sleepingAllowed: false
20                                 bodyType: Body.Dynamic
21                 fixtures: Box {
22                     anchors.fill: parent
23                     density: 1
24                     friction: 0.3
25                     restitution: 0.5
26                     categories: Box.Category2
27                     collidesWith: Box.Category1 | Box.Category3 | Box.Category4
28                 }
29                 rotation: Math.random() * 90;
30                 Rectangle {
31                     anchors.fill: parent
32                     color: "blue"
33                     opacity: 0.5
34                 }
35             }
36         }
37
38         Repeater {
39             model: 5
40             delegate: Body {
41                 x: index * 150 + 10;
42                 y: Math.random() * (screen.height / 3);
43                 width: 50;
44                 height: 50;
45                 sleepingAllowed: false
46                                 bodyType: Body.Dynamic
47                 fixtures: Box {
48                     anchors.fill: parent
49                     density: 1
50                     friction: 0.3
51                     restitution: 0.5
52                     categories: Box.Category3
53                     collidesWith: Box.Category1 | Box.Category2 | Box.Category4
54                 }
55                 rotation: Math.random() * 90;
56                 Rectangle {
57                     anchors.fill: parent
58                     color: "red"
59                     opacity: 0.5
60                 }
61             }
62         }
63
64         Repeater {
65             model: 5
66             delegate: Body {
67                 x: index * 150 + 10;
68                 y: Math.random() * (screen.height / 3);
69                 width: 50;
70                 height: 50;
71                 sleepingAllowed: false
72                 fixedRotation: true
73                                 bodyType: Body.Dynamic
74                 fixtures: Box {
75                     anchors.fill: parent
76                     density: 1
77                     friction: 0.3
78                     restitution: 0.5
79                     categories: Box.Category4
80                     collidesWith: Box.All
81                 }
82                 rotation: Math.random() * 90;
83                 Rectangle {
84                     anchors.fill: parent
85                     color: "green"
86                     opacity: 0.5
87                 }
88             }
89         }
90
91         Wall {
92             id: ground
93             height: 20
94             anchors { left: parent.left; right: parent.right; top: parent.bottom }
95         }
96         Wall {
97             id: ceiling
98             height: 20
99             anchors { left: parent.left; right: parent.right; bottom: parent.top }
100         }
101         Wall {
102             id: leftWall
103             width: 20
104             anchors { right: parent.left; bottom: ground.top; top: ceiling.bottom }
105         }
106         Wall {
107             id: rightWall
108             width: 20
109             anchors { left: parent.right; bottom: ground.top; top: ceiling.bottom }
110         }
111     }
112 }