在Phaser.io中使组内的对象与自身发生碰撞? [英] Make objects inside a group collide with themselves in Phaser.io?

查看:148
本文介绍了在Phaser.io中使组内的对象与自身发生碰撞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是关于phaser.io的.有人可以告诉我如何使组内的对象相互碰撞. 现在,当我这样做时,

This question is regarding phaser.io. Can someone show me how to make objects inside a group collide with each other. Right now when i do,

//board is the group and it has many elements
//Floor is where all the elements fall to
game.physics.arcade.collide(this.board, this.floor);

当组中的所有元素在同一位置撞击地板时,它们会彼此堆叠.换句话说,堆栈建立在一个位置,最新的堆栈隐藏前一个元素,而不是向上排列,在某种意义上,堆栈在另一个位置之上.如何使堆栈向上构建?如果您仅能向我展示如何使组内的元素发生碰撞,那将是很好的.谢谢.

All the elements inside the group stack on top of each other when they hit the floor at the same position. In other words the stack builds at one position, the latest one hiding the previous element and not upwards in the sense one on top of another at a higher position. How can i make the stack build upwards? If you could just show me how to make elements inside a group collide would be great. Thanks.

推荐答案

您可以将网上论坛与自己进行碰撞:

You can collide a Group with itself:

game.physics.arcade.collide(this.board, this.board);

尽管如此,我还是会在本教程中为您介绍添加一个简单的1d排序数组的方法,如果该组人口稠密,这将大有帮助:

Although on that note I would point you at this tutorial on adding a simple 1d sort array, which will help considerably if the Group is densely populated: http://ra3s.com/wordpress/dysfunctional-programming/pruning-collision-detection-with-a-1d-sort/

这篇关于在Phaser.io中使组内的对象与自身发生碰撞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆