「利用者:Moguri/BGE Collision API Proposal」の版間の差分

提供: wiki
移動先: 案内検索
(Created page with "=BGE Collision API= I don't yet know whether to use an event list or callbacks. ==CollisionEvent objects== Properties: * location * material * object (These I would like to i...")
(相違点なし)

2011年3月20日 (日) 10:18時点における版

BGE Collision API

I don't yet know whether to use an event list or callbacks.

CollisionEvent objects

Properties:

  • location
  • material
  • object

(These I would like to include)

  • normal
  • force

CollisionEvent list

Stored on KX_GameObjects. For each collision, two events are created and one is stored on each KX_GameObject in the collision.

Example:

for ce in obj.collisions:
	if ce.name == "Bomb":
		obj.endObject()

Collision callbacks

Collision callbacks are registered on KX_GameObjects. The callback functions take a KX_GameObject and a CollisionEvent object and do not return anything.

Example:

def col_bomb(self, ce):
	if ce.object.name == "Bomb":
		self.endObject()

obj.register(col_bomb)