コード例 #1
0
ファイル: ItemFactory.cs プロジェクト: zfogg/Bounce
        public static PaddleBall CreatePaddleBall(PhysicalScene scene, Paddle paddle)
        {
            var texture = BounceGame.ContentManager.Load<Texture2D>("dragonBall");
            var pb = new PaddleBall(scene, paddle, texture);

            pb.FixToPaddle(
                ConvertUnits.ToSimUnits(
                    Vector2.UnitY * pb.Texture.Height));

            return pb;
        }
コード例 #2
0
ファイル: PaddleBall.cs プロジェクト: zfogg/Bounce
        public PaddleBall(PhysicalScene scene, Paddle paddle, Texture2D texture)
            : base(scene, ConvertUnits.ToSimUnits(texture.Width / 2f))
        {
            this.paddle = paddle;
            this.Texture = texture;
            this.origin = new Vector2(Texture.Width / 2, Texture.Height / 2);

            Body.BodyType = BodyType.Dynamic;
            Body.IgnoreGravity = true;
            Body.Mass = 5f;
            Body.Restitution = 1.0725f;
            Body.Friction = 1f;

            scene.Input.OnKeyDown += new KeyboardEvent(onKeyDown);

            Body.OnCollision += new OnCollisionEventHandler(onCollision);
        }