Jump to content

Phaser class problems


The_dude8080
 Share

Recommended Posts

I am new to phaser and I am trying to set up a class named "Player". I want to create a group inside the class that contains different sprites that will serve as sensors for collision (hitboxes). Obviously I want the player phyisics to be enabled which I am not beeing able to get it done. I was previously able to enable physics for other sprites that were added the "normal way". Is it because I am using the isometric plugin and this changes somehow?

Also I am have previously tried to set the size of a sprite body but couldn't change its size (at least vissualy when debugging it I saw no difference on the grid) http://udof.org/phaser/iso/doc/Phaser.Plugin.Isometric.Body.html#setSize I am using "setSize(...)" I can change the the last 3 parameters and I see the difference. Not for the first 3 however.

Player = function (game, x, y) {

Phaser.Sprite.call(this, game, x, y, 'player');

    this.scale.x = 1; // this is working
    this.scale.y = 1; // this is too
    game.physics.isoArcade.enable(this); // NOT WORKING
    this.body.collideWorldBounds = true;   

};

Player.prototype = Object.create(Phaser.Sprite.prototype);
Player.prototype.constructor = Player;



//INSIDE CREATE FUNCTION //

 new_player = new Player(game,size_x/2 + 150,size_y/2 -100);
 game.add.existing(new_player);

Any ideas? Thank you

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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