简体   繁体   English

如何设置圆形相位器Arcade模式的物理尺寸

[英]How to set the physics size of a circle Phaser Arcade mode

Using Phaser I created a game in "Arcade Mode". 我使用Phaser在“街机模式”下创建了一个游戏。 The game has a snowball, and I need to set the physics size to a sprite that is not like a square (ie a circle). 游戏中有一个雪球,我需要将物理尺寸设置为不像正方形(即圆形)的精灵。 How do I do that? 我怎么做?

setSize doesn't have radius property: setSize没有radius属性:

setSize(width, height, offsetX, offsetY)

Phaser's Arcade physics system is based upon bounding rectangles. Phaser的Arcade物理系统基于边界矩形。 If you want to use the Arcade physics system for your game, then you'll need to represent your snowball as a rectangular object in the system (which doesn't need to be the same size as the sprite; it could be a smaller size within). 如果要在游戏中使用Arcade物理系统,则需要将雪球表示为系统中的矩形对象(它的大小不必与Sprite相同;它可以较小)内)。

If you want to use a circular size then you'll have to look at one of the other physics systems that Phaser supports. 如果要使用圆形尺寸,则必须查看Phaser支持的其他物理系统之一。 In your case P2 is probably what you're looking for. 在您的情况下, P2可能正是您想要的。

See the official Phaser example 'Collide Custom Bounds' for an example of using a circle to define bounds in P2. 有关使用圆定义P2中的边界的示例,请参见Phaser官方示例“碰撞自定义边界”

It effectively involves adding P2 physics to the object, or group the object is in, and then using something like snowball.body.setCircle(16); 它实际上涉及向对象添加P2物理特性,或将对象所在的对象分组,然后使用snowball.body.setCircle(16);类的东西snowball.body.setCircle(16);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM