Jump to content

Sprite Collision Detection in Phaser v2


DukeRanjan
 Share

Recommended Posts

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.

 

 

Regards

Duke Ranjan 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...