示例#1
0
        public void Setup()
        {
            nfloat w = Bounds.Width;
            nfloat h = Bounds.Height;

            if (w < h)
            {
                nfloat wTmp = w;
                w = h;
                h = wTmp;
            }

            // Setup the game overlays using SpriteKit
            SKScene skScene = SKScene.FromSize(new CGSize(w, h));

            skScene.ScaleMode = SKSceneScaleMode.ResizeFill;

            overlayGroup = SKNode.Create();
            skScene.AddChild(overlayGroup);
            overlayGroup.Position = new CGPoint(0f, h);

            // The Max icon
            SKSpriteNode sprite = SKSpriteNode.FromImageNamed("Images/MaxIcon.png");

            sprite.Position = new CGPoint(50f, -50f);

            overlayGroup.AddChild(sprite);
            sprite.XScale = sprite.YScale = 0.5f;

            for (int i = 0; i < 3; i++)
            {
                flowers [i]          = SKSpriteNode.FromImageNamed("Images/FlowerEmpty.png");
                flowers [i].Position = new CGPoint(110f + i * 40f, -50f);
                flowers [i].XScale   = flowers [i].YScale = 0.25f;
                overlayGroup.AddChild(flowers[i]);
            }

            // The peal icon and count.
            sprite          = SKSpriteNode.FromImageNamed("Images/ItemsPearl.png");
            sprite.Position = new CGPoint(110f, -100f);
            sprite.XScale   = sprite.YScale = 0.5f;
            overlayGroup.AddChild(sprite);

            pearlLabel          = SKLabelNode.FromFont("Chalkduster");
            pearlLabel.Text     = "x0";
            pearlLabel.Position = new CGPoint(152f, -113f);
            overlayGroup.AddChild(pearlLabel);

            // The D-Pad
            sprite          = SKSpriteNode.FromImageNamed("Images/dpad.png");
            sprite.Position = new CGPoint(100f, 100f);
            sprite.XScale   = sprite.YScale = 0.5f;
            skScene.AddChild(sprite);
            padRect = new CGRect(
                (sprite.Position.Y - DPAD_RADIUS) / w,
                1f - (sprite.Position.Y + DPAD_RADIUS) / h,
                2f * DPAD_RADIUS / w,
                2f * DPAD_RADIUS / h
                );

            // Assign the SpriteKit overlay to the SceneKit view.
            OverlayScene = skScene;

            // Setup the pinch gesture
            defaultFov = PointOfView.Camera.XFov;

            var pinch = new UIPinchGestureRecognizer {
                Delegate             = this,
                CancelsTouchesInView = false
            };

            pinch.AddTarget(() => PinchWithGestureRecognizer(pinch));

            AddGestureRecognizer(pinch);
        }