コード例 #1
0
ファイル: Nodes.cs プロジェクト: yxy332/monotouch-samples
        static MissileNode()
        {
            template = UnarchiveNode("missile", "sks");
            // use a local variable to avoid multiple virtual call to the `PhysicsBody` property
            var body = SKPhysicsBody.BodyWithCircleOfRadius(defaultSize);

            body.CategoryBitMask    = Category.Missile;
            body.ContactTestBitMask = Category.Ship | Category.Asteroid | Category.Planet | Category.Edge;
            body.CollisionBitMask   = 0;
            template.PhysicsBody    = body;
        }
コード例 #2
0
ファイル: Nodes.cs プロジェクト: yxy332/monotouch-samples
        public PlanetNode(PointF initialPosition, float size = defaultSize)
        {
            var path = new CGPath();

            path.AddArc(0, 0, size, 0, (float)Math.PI * 2f, true);
            Path        = path;
            StrokeColor = UIColor.Clear;
            FillColor   = UIColor.Green;
            Position    = initialPosition;
            // use a local variable to avoid multiple virtual call to the `PhysicsBody` property
            var body = SKPhysicsBody.BodyWithCircleOfRadius(size);

            body.CategoryBitMask    = Category.Planet;
            body.CollisionBitMask   = Category.Planet | Category.Edge;
            body.ContactTestBitMask = 0;
            PhysicsBody             = body;
        }
コード例 #3
0
        void Explode()
        {
            for (int i = 0; i < numberOfChunks; i++)
            {
                float angle    = myRand(0, (float)Math.PI * 2);
                float speed    = myRand(shipChunkMinimumSpeed, shipChunkMaximumSpeed);
                var   position = new PointF(myRand(Position.X - shipChunkDispersion, Position.Y + shipChunkDispersion),
                                            myRand(Position.Y - shipChunkDispersion, Position.Y + shipChunkDispersion));
                var explosion = new ExplosionNode(Scene, position);
                var body      = SKPhysicsBody.BodyWithCircleOfRadius(0.25f);
                body.CollisionBitMask   = 0;
                body.ContactTestBitMask = 0;
                body.CategoryBitMask    = 0;
                body.Velocity           = new CGVector((float)Math.Cos(angle) * speed, (float)Math.Sin(angle) * speed);
                explosion.PhysicsBody   = body;
                Scene.AddChild(explosion);
            }

            RunAction(SKAction.Sequence(
                          SKAction.WaitForDuration(removeShipTime),
                          SKAction.RemoveFromParent()
                          ));
        }