Hilfe
Parameter
entity% | Entity=Identität eines 3D-Objekts |
Rückgabewert
Anzahl der Kollisionen wird zurückgeliefert.
Beschreibung
Die Funktion CountCollisions ermittelt die Anzahl der Kollisionen, die seit der letzten UpdateWorld-Anweisung aufgetreten sind.
Gebe die Identität eines Objekts an, das auf Kollision überprüft werden soll.
Beispiel
Standardbeispiel:
SetBuffer BackBuffer()
camera = CreateCamera()
RotateEntity camera, 45, 0, 0
PositionEntity camera, 0, 15, - 10
light = CreateLight()
RotateEntity light, 45, 0, 0
sphere = CreateSphere(32)
EntityType sphere, 1
EntityRadius sphere, 1
PositionEntity sphere, 0, 11, 0
cube = CreateCube()
EntityType cube, 2
EntityColor cube, 0, 100, 0
PositionEntity cube, 0, - 5, 0
ScaleEntity cube, 10, 10, 10
cylinder = CreateCylinder(32)
EntityType cylinder, 2
EntityColor cylinder, 255, 0, 0
PositionEntity cylinder, 0, 7, 0
ScaleEntity cylinder, 2, 2, 2
Collisions 1, 2, 2, 2
While Not KeyDown(1)
x# = 0
y# = 0
z# = 0
If KeyDown(203) = 1 Then x# = - 0.1
If KeyDown(205) = 1 Then x# = 0.1
If KeyDown(208) = 1 Then z# = - 0.1
If KeyDown(200) = 1 Then z# = 0.1
MoveEntity sphere, x#, - 0.1, z#
UpdateWorld
RenderWorld
col = CountCollisions(sphere)
Text 0, 0, "Kollision(en):"
For i = 1 To col
Text 000, i * 20, "Entity=" + CollisionEntity(sphere, i)
Text 150, i * 20, "Surface=" + CollisionSurface(sphere, i)
Text 300, i * 20, "Triangle=" + CollisionTriangle(sphere, i)
Next
Flip
Wend
End
Siehe auch
ClearCollisions, CollisionEntity, Collisions, EntityCollided

