Esempio n. 1
0
        // Change Texture to disturbed texture
        public void ChangeTexture(bool disturb, double pointSpeed1)
        {
            // Default texture
            SKTexture sparkTexture3 = SKTexture.FromImageNamed("spark3");

            // Disturbed texture
            SKTexture sparkTexture4 = SKTexture.FromImageNamed("spark4");

            // Set custom fade and rotation actions
            if (disturb == true)
            {
                // Set disturbed texture
                Texture = sparkTexture4;

                // Fade Actions on the node
                // SKAction action1 = SKAction.FadeAlphaBy(-0.2f, 1);
                // SKAction action2 = SKAction.FadeAlphaBy(+0.2f, 1);
                // SKAction sequence = SKAction.Sequence(action1, action2);

                // Generated random rotation factor
                double rotateBy = rnd.NextDouble() * (2 - 1) + 1;
                RunAction(SKAction.RepeatActionForever(SKAction.RotateByAngle(NMath.PI, rotateBy)));

                // Set X Scaling related to PointSpeed1
                SKAction changeX1        = SKAction.ScaleXTo(1.1f, pointSpeed1);
                SKAction changeX2        = SKAction.ScaleXTo(0.9f, pointSpeed1);
                var      changeSequenceX = SKAction.Sequence(changeX1, changeX2);
                RunAction(SKAction.RepeatActionForever(changeSequenceX));

                // Set Y Scaling related to PointSpeed1
                SKAction changeY1        = SKAction.ScaleYTo(1.1f, pointSpeed1);
                SKAction changeY2        = SKAction.ScaleYTo(0.9f, pointSpeed1);
                var      changeSequenceY = SKAction.Sequence(changeY1, changeY2);
                RunAction(SKAction.RepeatActionForever(changeSequenceY));
            }

            // Set default texture
            else
            {
                Texture = sparkTexture3;
            }
        }