mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Add documentation on crop functionality Fix #6589
This commit is contained in:
parent
a74f99563b
commit
371a8b31a9
3 changed files with 16 additions and 10 deletions
|
@ -50,12 +50,14 @@ var Crop = {
|
|||
* Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just
|
||||
* changes what is shown when rendered.
|
||||
*
|
||||
* The crop size as well as coordinates can not exceed the the size of the texture frame.
|
||||
*
|
||||
* The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left.
|
||||
*
|
||||
* Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left
|
||||
* half of it, you could call `setCrop(0, 0, 400, 600)`.
|
||||
*
|
||||
* It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop
|
||||
* It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop
|
||||
* an area of 200x100 when applied to a Game Object that had a scale factor of 2.
|
||||
*
|
||||
* You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument.
|
||||
|
@ -68,10 +70,10 @@ var Crop = {
|
|||
* @method Phaser.GameObjects.Components.Crop#setCrop
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored.
|
||||
* @param {number} [y] - The y coordinate to start the crop from.
|
||||
* @param {number} [width] - The width of the crop rectangle in pixels.
|
||||
* @param {number} [height] - The height of the crop rectangle in pixels.
|
||||
* @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored.
|
||||
* @param {number} [y] - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height.
|
||||
* @param {number} [width] - The width of the crop rectangle in pixels. Cannot exceed the Frame width.
|
||||
* @param {number} [height] - The height of the crop rectangle in pixels. Cannot exceed the Frame height.
|
||||
*
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
|
|
|
@ -55,12 +55,14 @@ var TextureCrop = {
|
|||
* Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just
|
||||
* changes what is shown when rendered.
|
||||
*
|
||||
* The crop size as well as coordinates can not exceed the the size of the texture frame.
|
||||
*
|
||||
* The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left.
|
||||
*
|
||||
* Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left
|
||||
* half of it, you could call `setCrop(0, 0, 400, 600)`.
|
||||
*
|
||||
* It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop
|
||||
* It is also scaled to match the Game Object scale automatically. Therefore a crop rectangle of 100x50 would crop
|
||||
* an area of 200x100 when applied to a Game Object that had a scale factor of 2.
|
||||
*
|
||||
* You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument.
|
||||
|
@ -73,10 +75,10 @@ var TextureCrop = {
|
|||
* @method Phaser.GameObjects.Components.TextureCrop#setCrop
|
||||
* @since 3.11.0
|
||||
*
|
||||
* @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored.
|
||||
* @param {number} [y] - The y coordinate to start the crop from.
|
||||
* @param {number} [width] - The width of the crop rectangle in pixels.
|
||||
* @param {number} [height] - The height of the crop rectangle in pixels.
|
||||
* @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored.
|
||||
* @param {number} [y] - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height.
|
||||
* @param {number} [width] - The width of the crop rectangle in pixels. Cannot exceed the Frame width.
|
||||
* @param {number} [height] - The height of the crop rectangle in pixels. Cannot exceed the Frame height.
|
||||
*
|
||||
* @return {this} This Game Object instance.
|
||||
*/
|
||||
|
|
|
@ -485,6 +485,8 @@ var Frame = new Class({
|
|||
* Takes a crop data object and, based on the rectangular region given, calculates the
|
||||
* required UV coordinates in order to crop this Frame for WebGL and Canvas rendering.
|
||||
*
|
||||
* The crop size as well as coordinates can not exceed the the size of the frame.
|
||||
*
|
||||
* This is called directly by the Game Object Texture Components `setCrop` method.
|
||||
* Please use that method to crop a Game Object.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue