/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> /// <param name="texture">The texture.</param> /// <param name="color">The color.</param> /// <param name="spriteFont">The sprite font.</param> /// <param name="text">The text.</param> /// <param name="textColor">Color of the text.</param> public Button(Texture2D texture, Color color, SpriteFont spriteFont, String text, Color textColor) : base(texture, color, new Vector2(0, 0), new Vector2(1, 1), 0f) { _textLabel = new Label(spriteFont, text, textColor, new Vector2(0, 0), new Vector2(1, 1), 0); _state = BState.Up; _timer = 2f; }
/// <summary> /// Initializes a new instance of the <see cref="Button"/> class. /// </summary> /// <param name="state">The state.</param> /// <param name="texture">The texture.</param> /// <param name="color">The color.</param> /// <param name="position">The position.</param> /// <param name="scale">The scale.</param> /// <param name="angle">The angle.</param> /// <param name="timer">The timer.</param> /// <param name="textColor">Color of the text.</param> /// <param name="spriteFont">The sprite font.</param> /// <param name="text">The text.</param> public Button(BState state, Texture2D texture, Color color, Vector2 position, Vector2 scale, float angle, double timer, Color textColor, SpriteFont spriteFont = null, String text = "") : base(texture, color, position, scale, angle) { _textLabel = new Label(spriteFont, text, textColor, position, scale, angle); _state = state; _timer = timer; }
/// <summary> /// Initializes a new instance of the <see cref="SnakeEngine"/> class. /// </summary> public SnakeEngine(Texture2D buttonTexture2D, SpriteFont buttonTextSpriteFont) { _zoom = 10f; _angleLabel = new Label(buttonTextSpriteFont, "Degrees " , Color.Black); _rightRotationButtons = new Button[NumberOfFigures - 1]; _leftRotationButtons = new Button[NumberOfFigures]; _cubeVertices = new Triangle[NumberOfVertices*2]; for (int i = 0; i < NumberOfFigures; i++) { InitializeTetrahedron(i, true); InitializeTetrahedron(i, false); var i1 = i; if (i != NumberOfFigures) { _leftRotationButtons[i] = new Button(buttonTexture2D, Color.White, buttonTextSpriteFont, "L" + (i + 1), Color.Black) { Click = delegate { Rotate(FindCenterOfRotation(false, i1), i1, false); } }; } if (i == 0) continue; _rightRotationButtons[i - 1] = new Button(buttonTexture2D, Color.White, buttonTextSpriteFont, "R" + i, Color.Black) { Click = delegate { Rotate(FindCenterOfRotation(true, i1), i1, true); } }; } _clearButton = new Button(buttonTexture2D, Color.White, buttonTextSpriteFont, "CLEAR", Color.Black) { Click = delegate { for (int i = 0; i < NumberOfFigures; i++) { InitializeTetrahedron(i, true); InitializeTetrahedron(i, false); } _angleChange = 10; } }; GenerateClickListeners(buttonTexture2D, buttonTextSpriteFont); }