codermua

i cant use polygonal sprites with json

Recommended Posts

Hi, dear game developers.

I had seen that link on examples load-polygon-1 or 

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });

function preload() {

	game.load.image('contra2', 'assets/pics/contra2.png');

	//	Load our physics data exported from PhysicsEditor
	game.load.physics('physicsData', 'assets/physics/sprites.json');

}

var contra;
var start = false;

function create() {

	//	Enable p2 physics
	game.physics.startSystem(Phaser.Physics.P2JS);

	contra = game.add.sprite(400, 300, 'contra2');

	//	Enable the physics body on this sprite and turn on the visual debugger
	game.physics.p2.enable(contra, false);

	//	Clear the shapes and load the 'contra2' polygon from the physicsData JSON file in the cache
	contra.body.clearShapes();
	contra.body.loadPolygon('physicsData', 'contra2');

	//	Just starts it rotating
	game.input.onDown.add(function() { start = true; }, this);

}

function update() {

	if (start)
	{
		contra.body.rotateLeft(250);
	}

}

function render() {

}


, and i'm trying create json like that, since i saw that example. I saw some suggestions about physics editor or mapeditor tiled.  i installed it, but i have no idea about creating json like that despite researching how its doing on internet. Probably i need some help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.