public void Init(int id, Texture2D yourtexture) { texture = yourtexture; userData = new UserData(id, -1, false); base.Init(); myBody.FixtureList[0].Restitution = 1; }
private void CreateBorder(float width, float height, float borderWidth) { width = Math.Abs(width); height = Math.Abs(height); _anchor = BodyFactory.CreateBody(_world); left = BodyFactory.CreateBody(_world); right = BodyFactory.CreateBody(_world); up = BodyFactory.CreateBody(_world); down = BodyFactory.CreateBody(_world); UserData userData = new UserData(-1, 3, true); Vertices vert = new Vertices(); // top // counterclockwise Vertices vup = new Vertices(); vup.Add(new Vector2(0, 10)); vup.Add(new Vector2(0, 0)); vup.Add(new Vector2(1000, 0)); vup.Add(new Vector2(1000, 10)); up.CreateFixture(new PolygonShape(vup, 0.0f), userData); //Bottom down.CreateFixture(new PolygonShape(vup, 0.0f), userData); down.Position = new Vector2(0, 990); //Left Vertices vl = new Vertices(); vl.Add(new Vector2(0, 1000)); vl.Add(new Vector2(0, 0)); vl.Add(new Vector2(10, 0)); vl.Add(new Vector2(10, 1000)); left.CreateFixture(new PolygonShape(vl, 0.0f), userData); //Right right.CreateFixture(new PolygonShape(vl, 0.0f), userData); right.Position = new Vector2(990, 0); foreach (Fixture t in _anchor.FixtureList) { t.CollisionFilter.CollisionCategories = Category.All; t.CollisionFilter.CollidesWith = Category.All; t.Friction = _frictionValue; t.Restitution = _bouncyValue; } ContentManager content = Master.theMaster.game.Content; topBorder = content.Load<Texture2D>("images/BoarderHorizontal"); bottomBorder = content.Load<Texture2D>("images/BoarderHorizontal"); rightBorder = content.Load<Texture2D>("images/BoarderVertical"); leftBorder = content.Load<Texture2D>("images/BoarderVertical"); }
public void Init() { userData = new UserData(0, 0, true); userData.bIsPlayer = true; base.Init(); myBody.Position = new Vector2(200, 200); myBody.BodyType = BodyType.Dynamic; myBody.FixtureList[0].Restitution = 1.0f; myBody.LinearDamping = 0.0001f; texture = theMaster.game.Content.Load<Texture2D>("images/BlueSquareHero"); convertedEnemyTexture = theMaster.game.Content.Load<Texture2D>("images/BlueSquare"); collisionParticles.setTexture(0, theMaster.game.Content.Load<Texture2D>("images/Particles/Particle1")); collisionParticles.setTexture(1, theMaster.game.Content.Load<Texture2D>("images/Particles/Particle2")); collisionParticles.setTexture(2, theMaster.game.Content.Load<Texture2D>("images/Particles/Particle3")); collisionParticles.setTexture(3, theMaster.game.Content.Load<Texture2D>("images/Particles/Particle4")); }