DukeRanjan Posted November 4, 2014 Share Posted November 4, 2014 Hi Folks, I am new to Phaser framework. I have 6 sprites which are draggables. The codebase is as under:var circle = game.add.sprite(64.0, 55.0, "circle");circle.anchor.setTo(0.5, 0.5);var triangle = game.add.sprite(151.3, 55.3, "triangle");triangle.anchor.setTo(0.5, 0.5);var box = game.add.sprite(63.15, 118.55, "box");box.anchor.setTo(0.5, 0.5);var penta = game.add.sprite(151.25, 122.9, "penta");penta.anchor.setTo(0.5, 0.5);var plus = game.add.sprite(62.95, 179.25, "plus");plus.anchor.setTo(0.5, 0.5);var rect = game.add.sprite(151.4, 182.9, "rect");rect.anchor.setTo(0.5, 0.5); var arrItem = new Array(circle, triangle, box, penta, plus, rect); for (var i = 0; i < arrItem.length; i++) { var oItem = arrItem[i]; oItem.inputEnabled = true; oItem.input.enableDrag(false, true); oItem.events.onDragStart.add(player.onItemDragStart,this); oItem.events.onDragStop.add(player.onItemDragStop,this);}And the droppables code are as under:for (var i = 0; i < currentDesign.shape.length; i++) { var shape = currentDesign.shape[i]; var aShape = game.add.sprite(shape.x, shape.y, "circle"); shape.inputEnabled = true; aShape.anchor.setTo(0.5, 0.5); player.members.arrDesignItems.push(aShape);}How to do collision detection? Please guide step by step. RegardsDuke Ranjan Link to comment Share on other sites More sharing options...
eguneys Posted November 5, 2014 Share Posted November 5, 2014 Search for "collision" in the phaser examples: http://examples.phaser.io/ Link to comment Share on other sites More sharing options...
Recommended Posts