Hi I am trying to create a class so I can use buttons globally throughout my code but I am doing something wrong and I can't figure it out.

My Global class code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Arcanoid

    public class GlobalClass
        public static void ButtonsControl()
            Button Fullscreen = new Button();

        public static int playx = 301;
        public static int playy = 153;

        public static int fsx = 301;
        public static int fsy = 153;



And my Form1.cs error: I put qoutes around where the error was!

private void timer2_Tick(object sender, EventArgs e)
            GlobalClass.playx = GlobalClass.playx * 3;
            GlobalClass.playy = GlobalClass.playy * 3;
            Play.Location = new  Point ( GlobalClass.playx, GlobalClass.playy );

            GlobalClass.fsx = GlobalClass.fsx * 3;
            GlobalClass.fsy = GlobalClass.fsy * 3;
            GlobalClass."ButtonsControl".Fullscreen.Location = new Point(GlobalClass.fsx, GlobalClass.fsy);
            timer2.Enabled = false;


Edited by Jive_1

1 Year
Discussion Span
Last Post by ddanbe

'I am doing something wrong and I can't figure it out.'
Unless you don't tell us WHAT you are doing wrong(wrong behaviour, errors etC.) we can't figure it out either, by oly looking at your code.
Line 9 in your timer2_Tick event handler seems far from OK.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.