Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kazius

Pages: [1]
1
General / Problem with my Game class and const sf::Input
« on: February 22, 2010, 08:20:08 pm »
aye, thanks. It is working now fine. I forgot that there is something like the initializer list  :lol: .
greetz

2
General / Problem with my Game class and const sf::Input
« on: February 20, 2010, 08:52:43 pm »
Hi. Yes that was a mistake in my code, but i wasn't my problem. I have to declare a const variable before, but there i have no window and so i can't initialize it.

3
General / Problem with my Game class and const sf::Input
« on: February 20, 2010, 06:36:33 pm »
Hi guys. I am new to sfml, so i am still testing it.
First here is the beginning of my Game class:
Code: [Select]

class c_Game
{
private:
sf::RenderWindow* screen;
sf::Event* events;
c_Object* player;
c_Object* object;
float eTime;
const sf::Input input;
public:
c_Game()
{
screen = new sf::RenderWindow(VideoMode(800,600,32), "hi");
screen->UseVerticalSync(true);
player=new c_Object(0,0,100,100,sf::Color(0,255,0,100));
object=new c_Object(300,300,100,100,sf::Color(100,100,0,100));
events=new sf::Event();
input=screen->GetInput();
}
.
.
.

So, you can see it contains my window, events, my timer...and my sf::Input. And there is my problem: The function screen->(GetInput) returns a constant sf::Input. But i can't declare a const before, because i don't have my window yet.
Is there a way to get sf::Input without const?

Normally i wanted to handle my input like this:
Code: [Select]

if (input.IsKeyDown(Key::D))
{
player->Move(500*eTime,0);
}

If i leave out the variable input and use screen->GetInput() it works, but i don't think it's very efficient.
Code: [Select]

if (screen->GetInput().IsKeyDown(Key::D))
{
player->Move(500*eTime,0);
}

Pages: [1]