~ahayzen/volleyball2d/utopic

« back to all changes in this revision

Viewing changes to scenes/GameScene.qml

* Improvements to tap based controls
* Bump version to 0.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
                id: point1
160
160
                onPressedChanged: {
161
161
                    if (pressed) {
162
 
                        if (x < gameScene.width / 3) {
 
162
                        if (multiTouchArea.inLeft(x)) {
163
163
                            human.leftPressed = true
164
164
                            human.rightPressed = false
165
 
                        } else if (gameScene.width / 3 <= x && x <= gameScene.width - (gameScene.width / 3)) {
 
165
                        } else if (multiTouchArea.inCenter(x)) {
166
166
                            human.jump()
167
 
                        } else {
 
167
                        } else if (multiTouchArea.inRight(x)) {
168
168
                            human.leftPressed = false
169
169
                            human.rightPressed = true
170
170
                        }
178
178
                id: point2
179
179
                onPressedChanged: {
180
180
                    if (pressed) {
181
 
                        human.jump();
 
181
                        if (!multiTouchArea.inCenter(point1.x)) {
 
182
                            human.jump();
 
183
                        } else {
 
184
                            if (multiTouchArea.inLeft(x)) {
 
185
                                human.leftPressed = true
 
186
                                human.rightPressed = false
 
187
                            } else if (multiTouchArea.inRight(x)) {
 
188
                                human.leftPressed = false
 
189
                                human.rightPressed = true
 
190
                            }
 
191
                        }
182
192
                    }
183
193
                }
184
194
            }
185
195
        ]
 
196
 
 
197
        function inCenter(x) {
 
198
            return !inLeft(x) && !inRight(x);
 
199
        }
 
200
 
 
201
        function inLeft(x) {
 
202
            return x < gameScene.width / 3;
 
203
        }
 
204
 
 
205
        function inRight(x) {
 
206
            return x > gameScene.width - (gameScene.width / 3)
 
207
        }
186
208
    }
187
209
 
188
210
    // Motion controls