Jump to content

Can't see the player


Tarkunian
 Share

Recommended Posts

Hi guys!

First of all i am importing tilemap and it's working ok.

Then i am adding a player as suggested here: http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game

Problem is i can see only tiles, player is invisible!

Code is below:

var game = new Phaser.Game(640, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });var map;var tileset;var player;var layer_background;var layer_ground;var a;function preload() {	game.load.spritesheet('hero', 'assets/hero.png', 57, 84);	game.load.image('tileset', 'assets/tilemap.png');	game.load.tilemap('map', 'assets/map.json', null, Phaser.Tilemap.TILED_JSON);} function create() {	game.physics.startSystem(Phaser.Physics.ARCADE);	player = game.add.sprite(0, 0, 'hero');	game.physics.arcade.enable(player);	player.body.bounce.y = 0.2;    player.body.gravity.y = 300;    player.body.collideWorldBounds = true;	player.animations.add('left', [0, 1, 0, 2], 7, true);    player.animations.add('right', [3, 4, 3, 5], 7, true);	map = game.add.tilemap('map');	map.addTilesetImage('tilemap','tileset'); // !!!!	layer_background = map.createLayer("Background");	layer_ground = map.createLayer("Ground");	layer_ground.resizeWorld();	} function update() {	game.physics.arcade.collide(player, layer_ground);}

Thanks in advance!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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