axiosengine 

axiosengine Commit Details


Date:2012-05-17 20:39:54 (12 years 4 months ago)
Author:Natalie Adams
Branch:master
Commit:b8786c2aaff266fbe5611acf409c146741515871
Parents: f2272b05558f2ad1902b05979272c77e5d56ed8e
Message:Adding Contact extension

Changes:

File differences

axios/Engine/Extensions/Contact.cs
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FarseerPhysics.Dynamics.Contacts;
using Microsoft.Xna.Framework;
namespace Axios.Engine.Extensions
{
public enum CollisionDirection
{
Right,
Left,
Top,
Bottom
}
public static class AxiosExtensions_Contact
{
/// http://farseerphysics.codeplex.com/discussions/281783
/// <summary>
/// Returns the direction that the collision happened.
/// Should be used in the event OnAfterCollision
/// </summary>
/// <param name="c"></param>
/// <returns></returns>
public static CollisionDirection Direction(this Contact c)
{
CollisionDirection direction;
// Work out collision direction
Vector2 colNorm = c.Manifold.LocalNormal;
if (Math.Abs(colNorm.X) > Math.Abs(colNorm.Y))
{
// X direction is dominant
if (colNorm.X > 0)
direction = CollisionDirection.Right;
else
direction = CollisionDirection.Left;
}
else
{
// Y direction is dominant
if (colNorm.Y > 0)
direction = CollisionDirection.Top;
else
direction = CollisionDirection.Bottom;
}
return direction;
}
}
}

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.07330s using 14 queries.