User Tools

Site Tools


en:examples:orx_scroll:collisions_with_scrollobjects

Collisions with ScrollObjects

Collisions can be tested in ScrollObjects using the OnCollide function. The incoming _poCollider is the ScrollObject that is colliding with this ScrollObject.

Also, the parts of both ScrollObjects that are colliding are available in the function.

orxBOOL Enemy::OnCollide(ScrollObject *_poCollider,
	orxBODY_PART *_pstPart,
	orxBODY_PART *_pstColliderPart,
	const orxVECTOR &_rvPosition,
	const orxVECTOR &_rvNormal)
	{
		if (_poCollider == orxNULL) {
			return orxTRUE;
		}
 
		const orxSTRING colliderName = _poCollider->GetModelName();
		if (orxString_SearchString(colliderName, "Ship") != orxNULL) {
			const orxSTRING shipPartName = orxBody_GetPartName(_pstColliderPart);
			const orxSTRING enemyPartName = orxBody_GetPartName(_pstPart);
		}
 
		return orxTRUE;
	}
}

en/examples/orx_scroll/collisions_with_scrollobjects.txt · Last modified: 2022/07/14 05:55 (22 months ago) by sausage