al_amanat
al_amanat

Reputation: 615

Non-rectangular crop Phaser.Sprite or Phaser.Image

I have an image already preloaded in Phaser.State:

game.load.image(name, url);

I would like to use it in two different scenarios:

  1. As image (rendered in full-size without any cropping)
  2. As sprite source (rendered partially, cropped by hex)

First scenario is simple, but I can't find solution for second one. Phaser.Sprite.crop applies only Phaser.Rectangle and I can't put Phaser.Polygon into this method. How can I solve this problem?

PS: Of course, I don't want to download second (cropped) version of the image.

Upvotes: 1

Views: 1290

Answers (1)

Yan Sokalau
Yan Sokalau

Reputation: 38

Try to use alpha mask like here

But in this case you need upload an image of mask (your polygon).

Upvotes: 2

Related Questions