phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.16k stars 7.1k forks source link

To Review: Crop and TextureCrop GameObject Components #6832

Closed zekeatchan closed 2 months ago

zekeatchan commented 5 months ago

Currently these 2 components exist:

  1. Phaser.GameObjects.Components.TextureCrop (for texture based objects ie. Sprite, Image, Particle, Video)
  2. Phaser.GameObjects.Components.Crop (for non texture objects ie. Text and TileSprite)

Both components have identical functions with TextureCrop having additional setTexture and setFrame methods.

Do we still need to have separate components or can it be merged into a single component in future releases?

photonstorm commented 2 months ago

I looked at this the other day while going through the docs because there are several duplicated functions between these two mixins. This can't become one single component. What it could maybe do is become 'Crop', and then you add a second component for the 'Texture' side of it. Which is still two components, but it would eliminate a little bit of duplicate code.

Given the restructure we'll do for Phaser v4 I don't think it's worth changing this at this late stage.