Phaser.Component. Crop

new Crop()

The Crop component provides the ability to crop a texture based Game Object to a defined rectangle, which can be updated in real-time.

Source - gameobjects/components/Crop.js, line 13

Members

cropRect :Phaser.Rectangle

The Rectangle used to crop the texture this Game Object uses. Set this property via crop. If you modify this property directly you must call updateCrop in order to have the change take effect.

Source - gameobjects/components/Crop.js, line 24

Methods

crop(rect, copy)

Crop allows you to crop the texture being used to display this Game Object. Setting a crop rectangle modifies the core texture frame. The Game Object width and height properties will be adjusted accordingly.

Cropping takes place from the top-left and can be modified in real-time either by providing an updated rectangle object to this method, or by modifying cropRect property directly and then calling updateCrop.

The rectangle object given to this method can be either a Phaser.Rectangle or any other object so long as it has public x, y, width, height, right and bottom properties.

A reference to the rectangle is stored in cropRect unless the copy parameter is true, in which case the values are duplicated to a local object.

Parameters:
Name Type Argument Default Description
rect Phaser.Rectangle

The Rectangle used during cropping. Pass null or no parameters to clear a previously set crop rectangle.

copy boolean <optional>
false

If false cropRect will be stored as a reference to the given rect. If true it will copy the rect values into a local Phaser Rectangle object stored in cropRect.

Source - gameobjects/components/Crop.js, line 49

updateCrop()

If you have set a crop rectangle on this Game Object via crop and since modified the cropRect property, or the rectangle it references, then you need to update the crop frame by calling this method.

Source - gameobjects/components/Crop.js, line 86
Phaser Copyright © 2012-2015 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.2 on Thu Feb 18 2016 14:40:59 GMT+0000 (GMT Standard Time) using the DocStrap template.

快捷菜单

注意:只有登录才能全文翻译,每个新用户赠送300会员币。
赚取方法:文章评论+1000,分享网站截图给站长+3000,另充10元+100万会员币
支持一下记得截图给站长!

VIP限时免费阅读!登录可得1万币尽情中文阅读!


记得CTRL+D收藏!
站长微信:
支持自学php网
如有问题,记得强刷一下.

  • cropRect :Phaser.Rectangle - 属性
  • crop(rect, copy) - 方法
  • updateCrop() - 方法