Phaser.Component. PhysicsBody

new PhysicsBody()

The PhysicsBody component manages the Game Objects physics body and physics enabling. It also overrides the x and y properties, ensuring that any manual adjustment of them is reflected in the physics body itself.

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

Members

body :Phaser.Physics.Arcade.Body|Phaser.Physics.P2.Body|Phaser.Physics.Ninja.Body|null

body is the Game Objects physics body. Once a Game Object is enabled for physics you access all associated properties and methods via it.

By default Game Objects won't add themselves to any physics system and their body property will be null.

To enable this Game Object for physics you need to call game.physics.enable(object, system) where object is this object and system is the Physics system you are using. If none is given it defaults to Phaser.Physics.Arcade.

You can alternatively call game.physics.arcade.enable(object), or add this Game Object to a physics enabled Group.

Important: Enabling a Game Object for P2 or Ninja physics will automatically set its anchor property to 0.5, so the physics body is centered on the Game Object.

If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics.

Type:
Source - gameobjects/components/PhysicsBody.js, line 91

x :number

The position of the Game Object on the x axis relative to the local coordinates of the parent.

Source - gameobjects/components/PhysicsBody.js, line 98

y :number

The position of the Game Object on the y axis relative to the local coordinates of the parent.

Source - gameobjects/components/PhysicsBody.js, line 124

Methods

<static> postUpdate()

The PhysicsBody component postUpdate handler. Called automatically by the Game Object.

Source - gameobjects/components/PhysicsBody.js, line 61

<static> preUpdate()

The PhysicsBody component preUpdate handler. Called automatically by the Game Object.

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

快捷菜单

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

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


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

  • body :Phaser.Physics.Arcade.Body|Phaser.Physics.P2.Body|Phaser.Physics.Ninja.Body|null - 属性
  • x :number - 属性
  • y :number - 属性
  • postUpdate() - 方法
  • preUpdate() - 方法