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 - danik550

Pages: [1]
1
General / Re: Sharing SFML variable between 2 classes
« on: May 21, 2019, 02:46:05 pm »
You didn't define constructor for Player class, that's why linking fails.

Thanks!!!
I had a constructor but not the default one with no arguments

Is it okay that have both?

like this

Player(with arguments);
Player();

2
General / Re: Sharing SFML variable between 2 classes
« on: May 21, 2019, 01:30:31 pm »
Please post the error you're getting.
Did you include "player.h" in collider.cpp?

Here is the error that pops up at runtime not as I put it in.
The error appears where ever I try putting it in.

Is this the right way of accessing other variables or am I doing something wrong?

3
General / Sharing SFML variable between 2 classes
« on: May 21, 2019, 12:46:19 pm »
Hey so basically I am developing a game and I came across a problem of not knowing how to use a variable in a class that has been made in a different class.

Basically

My player.h class looks like this

class Player
{
public:
       sf::Vector2f velocity;

and in the player.cpp I do things to this velocity.

However I want to use this variable for checking purposes in my collider.cpp class. How can I access this velocity variable in a different class?

I tried Player A;
A.velocity;

and so on but I ended up with some external library error.

I can screenshot code if it will help

Pages: [1]
anything