Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C#-Quelltext |
|
1 2 3 4 5 |
protected override void Initialize() { base.Initialize(); world.ContactManager.PreSolve += new PreSolveDelegate(PreSolve); } |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
void PreSolve(Contact contact, ref Manifold oldManifold) { Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; if (fixtureB.CollisionCategories == Category.Cat15) { contact.Enabled = false; } } |
C#-Quelltext |
|
1 2 3 4 5 6 |
playerrect = BodyFactory.CreateCircle(world, 0.25f, 1.0f); playerrect.BodyType = BodyType.Dynamic; playerrect.Position = new Vector2(5.0f, 0f); playerrect.AngularDamping = 0.4f; playerrect.Restitution = 0.5f; playerrect.LinearVelocity = new Vector2(0, 2.0f); |
C#-Quelltext |
|
1 2 3 4 |
reccoin = BodyFactory.CreateRectangle(world, 0.64f, 0.64f, 1.0f); reccoin.BodyType = BodyType.Static; reccoin.Position = new Vector2(5.0f, 3.16f); reccoin.CollisionCategories = Category.Cat15; |
C#-Quelltext |
|
1 |
f.IsSensor = true; |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Bei einer der beiden gibst Du eine CollisionCategory an, bei der anderen nicht.
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Benutzt du jetzt einen ContactListener? Wenn nein, dann füge einen bitte hinzu Bei dem ContactListener gibt es dann die Methode BeginContact, wo du dein Coin "entfernen" kannst. Um zu wissen welches Objekt hinter dem Fixture steckt, solltest du bei den Bodies noch die UserData setzen.
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
class MyContactListener: ContactListener { void BeginContact(Contact contact) { /* handle begin event */ } void EndContact(Contact contact) { /* handle end event */ } void PreSolve(Contact contact, ref Manifold oldManifold) { Fixture fixtureA = contact.FixtureA; Fixture fixtureB = contact.FixtureB; if (fixtureB.CollisionCategories == Category.Cat10) { contact.Enabled = false; } } void PostSolve(Contact contact, ref ContactImpulse impulse) { /* handle post-solve event */ } } |
Werbeanzeige