zomm Posted November 27, 2014 Report Share Posted November 27, 2014 Hi all, I started to learn group in Phaser. And here is my code:function onCreate() { var arr = []; game.stage.backgroundColor = 0xffffff; boxes = game.add.group(); blue = boxes.create(0, 0, "blue"); yellow = boxes.create(blue.width, 0, "yellow"); red = boxes.create(0, blue.height, "red"); green = boxes.create(blue.width, blue.height, "green"); arr.push(blue); arr.push(yellow); arr.push(red); arr.push(green); for (var i = 0; i < arr.length; i++) { game.physics.arcade.enable(arr[i]); arr[i].body.immovable = true; } boxes.enableBody = true; boxes.physicsBodyType = Phaser.Physics.Arcade; boxes.x = game.width / 2; boxes.y = game.height / 2 + 100; boxes.pivot.x = blue.width; boxes.pivot.y = blue.height; boxes.scale.setTo(3); circle = game.add.graphics(0, 0); circle.beginFill(0xffffff); circle.drawCircle(boxes.x, boxes.y, 60); mask = game.add.graphics(0, 0); mask.beginFill(0xffffff); mask.drawCircle(boxes.x, boxes.y, 100); boxes.mask = mask; drop = createDrop(game.width / 2 - 8, -30); cursor = game.input.keyboard.createCursorKeys();}function onUpdate() { timer++; if (timer == 150) { //createDrop .... } // check game input to rotate boxes group .... game.physics.arcade.overlap(drop, boxes, onCollide, null, this);}function onCollide() { // nerver hit console.log("collide");}function createDrop(x, y) { // create random drop color .... if (drop != null) { var number = 100 * (rand * 0.5 + Math.random()); drop.anchor.setTo(0.5, 0.5); drop.scale.setTo(0.5, 0.5); game.physics.arcade.enable(drop); drop.body.gravity.y = number < 100 ? 100 : number; console.log(drop.body.gravity.y); } return drop;The problem here is the function onCollide() is not hit. Can you give me a hint to solve this?Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.