Jump to content

  • Log In with Google      Sign In   
  • Create Account

Askr

Member Since 13 Sep 2012
Offline Last Active Jan 16 2014 04:14 AM

Posts I've Made

In Topic: Which engine for 3D games using C#?

08 January 2014 - 08:44 AM

Many people claim Unity to be slow under certain conditions (like using physics excessively), but it's probably still your best bet until you've got something more serious going on you're willing to pay a substantial amount for.


In Topic: Space Ship Building & Simulation Games - Wow !

08 January 2014 - 08:37 AM

Yeah, Kerbal Space Program is also quite playable already with career mode/science. Also the physics are way more realistic than in Space Engineers. :)


In Topic: Custom GUI - Assigning functions to buttons

18 December 2012 - 01:13 AM

Try replacing

myButton.Click += new Action(myButton_Click);
with
myButton.Click += myButton_Click;
or
myButton.Click += () => {Console.Write("foo");};

From what I can tell in the MSDN article, the constructor format of Action doesn't do what you're thinking it does. I'll gladly take some correction on that if I didn't search deep enough though.

Sorry, this doesn't work. It doesn't even compile due to syntax errors.

I would track the mouse position and whether or not it's been clicked in the Window class, and then if the position of the cursor is inside of myButton when a click is dispatched call myButton.OnClick().

That was my thought as well. Since you already made a GUI: How did you listen for the mouse? Did you add an own class for this or where did you put it? :)

In Topic: Custom GUI - Assigning functions to buttons

14 December 2012 - 03:10 AM

Sorry for being absent from this topic so long, but I came around testing all your input just now. :]

Everything compiles well enough and I'm almost positive I didn't write anything too stupid, but somehow it just doesn't work. Let me paste some code and tell you what it does (and more importantly, what it does not):

This is from my Program.cs - I spared out the parts I don't consider interesting (FillColor and the like).
Window myWindow = new Window(50, 50, 400, 200);
Button myButton = new Button(0, 0, 150, 25);
myButton.setFillColor(new Color(255, 0, 0));
myButton.Click += new Action(myButton_Click);
myWindow.Add(myButton);
		  
myWindow.Draw();
while (MainWindow.IsOpen())
{
	MainWindow.DispatchEvents();
	MainWindow.Display();
}

[...]

static void myButton_Click()
{
	Console.Write("foo");
}

This is my button class
public event Action Click;
protected virtual void OnClick()
{
	if (Click != null)
		Click();
}

public Button(int x, int y, int w, int h)
{
	this.X = x;
	this.Y = y;
	this.Width = w;
	this.Height = h;
}

When I run the program the window with a button inside of it pops up, but wherever I click, the corresponding method just isn't called. It came to me that I don't have anything defined yet that does any mouse handling, so I figured I have to do this first. Here however I'm at a loss again. :/ Right now I have this Class called "GuiItem" from which "Button" and "Window" inheret. Should I add MouseEventHandlers for keeping track of the mouse in there, or rather create something new?

In Topic: Custom GUI - Assigning functions to buttons

28 November 2012 - 03:46 AM

Gtk# is being used in games as well as other programs.

Is that so? I figured from a quick overview that it was not. Then I shall look into it some more. :)

PARTNERS