Jump to content

Error on crop - Sprite extended class


NotAnExecutive
 Share

Recommended Posts

Hi, guys.

First of all, I've found Phaser amazing. And though my knowledge of Javascript is pretty basic, almost everything has been done without too many problems.

 

I got a problem with sprite cropping.

So I extended Sprite...

var cropRect;var some_obj;Medidor = function(game, x, y, someObject) {      Phaser.Sprite.call(this, game, x, y, 'medidor');        [...]        this.cropEnabled = true;    cropRect = new Phaser.Rectangle(0, 0, this.width/2, this.height);    this.crop(cropRect);        [...]    game.add.existing(this);};Medidor.prototype = Object.create(Phaser.Sprite.prototype);  Medidor.prototype.constructor = Medidor;Medidor.prototype.update = function() {    [...]    this.updateCrop();};

But when I run the game, an error appears:

TypeError: this.crop is not a function

I have even followed the example here:

http://examples.phaser.io/_site/view_full.html?d=sprites&f=dynamic+crop.js&t=dynamic%20crop

 

I don't know what I am doing wrong :/

 

Any ideas?

 

Thanks in advance,

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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