HI All,
in one class I want to be able to enable a timer in a different class. I was thinking of adding a support method to class and use that one to enable the timer instead of accessing the timer directly ( not sure if that makes even any sense).
At the moment I have something like this
using System; using System.Timers; using System.Diagnostics; using System.Linq; using NetGore; using NetGore.Graphics; using NetGore.Graphics.GUI; using SFML.Graphics; using SFML.Window; namespace DemoGame.Client { public class BattleScreenForm : Form { Timer BeginTimer; /// <summary> /// Initializes a new instance of the <see cref="BattleScreenForm"/> class. /// </summary> /// <param name="parent">The parent.</param> public BattleScreenForm(Control parent, Vector2 pos) : base(parent, pos, new Vector2(1024, 768)) { BeginTimer = new Timer(); BeginTimer.Interval = 50; BeginTimer.Elapsed += new ElapsedEventHandler(BeginTimer_Tick); } public void EchteBegin() { BeginTimer.Enabled = true; } public void BeginTimer_Tick(object sender, EventArgs e) { // do some stuff } } }
in the other class I have something like this
BattleScreenForm Newbattle = new BattleScreenForm(......., new Vector2(1024, 768)); Newbattle.EchteBegin();
The problem is that I don't know what I have to put in the (...) of the new BattleScreenForm(). is it (Control parent, Vector2 pos) and if so what do I have to put in there for the control parent part because I tried several things like NetGore.Graphics.GUI.Panel but that ofcourse is a type instead of variable.
I hope someone clever understands what Í just said and can help me out.
Thanks in advance
Problem solved.
I just found out I could simple use
GameplayScreen.BattleScreenForm.EchteBegin();to acces the method