Skip to content

Sprite ​

Phaser v4.1.0 · 英文原文

Matter 物理Sprite游戏对象.

这是一个已启用的Sprite, 与 Matter.js 物理引擎一起使用。 它将标准 Phaser Sprite 的全部渲染和动画能力与 Matter. js 物理机体相结合, 使其能够参与复杂的物理模拟, 包括多边形碰撞、 关节、 弹簧和制约 。

与使用简单的轴线相接的边框或圆圈的Arcade Physics不同,Matter.js支持任意的凸轮和凸轮多边形形状、复合体和现实的刚性体动力学。当您需要物理的这个水平的忠实度时,使用这个类来进行动画游戏对象。

构造时, 默认会创建一个与 sprite 框架尺寸相匹配的矩形体。 您可以通过提供 。 shape 属性在 options 配置对象,或调用其中之一 setBody, setRectangle, setCircle, setPolygon,或 ,或 , setTrapezoid 创建后的方法。

斯普林特游戏对象用于在游戏中显示静态和动画图像。斯普林特可以有输入事件和物理体,也可以被调色,有色,有卷轴和动画.

斯普丽特和图像游戏对象的主要区别在于无法动画图像。因此,斯普丽特需要花费更长的时间来处理,并且由于动画组件而具有更大的API脚印。如果不需要动画,那么可以安全地使用图像来替换所有情况下的斯普丽特.

构造函数

new Sprite(world, x, y, texture, [frame], [options])

参数

名称类型可选说明
worldPhaser.Physics.Matter.World否提到这个实体,这个机构所属的世界实例。
xnumber否这个游戏对象在世界的横向位置.
ynumber否此游戏对象在世界的垂直位置 。
texturestring | Phaser.Textures.Texture否此游戏对象将使用用于渲染的纹理的键或实例, 如保存在纹理管理器中 。
framestring | number是游戏对象正在用此渲染的纹理的可选框架 。
optionsPhaser.Types.Physics.Matter.MatterBodyConfig是一个可选的 body 配置对象,用于设定创建时的初始 body 属性 。

作用域: static

继承

Phaser.GameObjects.Sprite
Phaser.Physics.Matter.Components.Bounce
Phaser.Physics.Matter.Components.Collision
Phaser.Physics.Matter.Components.Force
Phaser.Physics.Matter.Components.Friction
Phaser.Physics.Matter.Components.Gravity
Phaser.Physics.Matter.Components.Mass
Phaser.Physics.Matter.Components.Sensor
Phaser.Physics.Matter.Components.SetBody
Phaser.Physics.Matter.Components.Sleep
Phaser.Physics.Matter.Components.Static
Phaser.Physics.Matter.Components.Transform
Phaser.Physics.Matter.Components.Velocity
Phaser.GameObjects.Components.Alpha
Phaser.GameObjects.Components.BlendMode
Phaser.GameObjects.Components.Depth
Phaser.GameObjects.Components.Flip
Phaser.GameObjects.Components.GetBounds
Phaser.GameObjects.Components.Mask
Phaser.GameObjects.Components.Origin
Phaser.GameObjects.Components.ScrollFactor
Phaser.GameObjects.Components.Size
Phaser.GameObjects.Components.Texture
Phaser.GameObjects.Components.Tint
Phaser.GameObjects.Components.Transform
Phaser.GameObjects.Components.Visible

源码:src/physics/matter-js/MatterSprite.js#L15
引入版本:3.0.0

继承的成员 ​

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.Flip:

From Phaser.GameObjects.Components.Lighting:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.RenderNodes:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.TextureCrop:

From Phaser.GameObjects.Components.Tint:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Sprite:

From Phaser.Physics.Matter.Components.Mass:


公开成员 ​

world ​

world: Phaser.Physics.Matter.World ​

说明:

提到这个实体,这个机构所属的世界实例。

源码:src/physics/matter-js/MatterSprite.js#L122
引入版本:3.0.0


继承的方法 ​

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Filters:

From Phaser.GameObjects.Components.Flip:

From Phaser.GameObjects.Components.GetBounds:

From Phaser.GameObjects.Components.Lighting:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.RenderNodes:

From Phaser.GameObjects.Components.RenderSteps:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.TextureCrop:

From Phaser.GameObjects.Components.Tint:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Sprite:

From Phaser.Physics.Matter.Components.Bounce:

From Phaser.Physics.Matter.Components.Collision:

From Phaser.Physics.Matter.Components.Force:

From Phaser.Physics.Matter.Components.Friction:

From Phaser.Physics.Matter.Components.Gravity:

From Phaser.Physics.Matter.Components.Mass:

From Phaser.Physics.Matter.Components.Sensor:

From Phaser.Physics.Matter.Components.SetBody:

From Phaser.Physics.Matter.Components.Sleep:

From Phaser.Physics.Matter.Components.Static:

From Phaser.Physics.Matter.Components.Transform:

From Phaser.Physics.Matter.Components.Velocity:



社区翻译