SFML community forums

Help => Graphics => Topic started by: The_Mezentine on July 26, 2011, 06:32:00 am

Title: Passing sprites, images and other things?
Post by: The_Mezentine on July 26, 2011, 06:32:00 am
Hey, so this is something of a beginner question but I'm running into some errors trying to compile the following:
Ball.h
Code: [Select]
#include<SFML\Graphics.hpp>

class Ball{
Private:
sf::Vector2f Velocity;
sf::Sprite BallSprite;
Public:
Ball(sf::Image &Image);
~Ball();
//void Rebound(sf::Vector2f & Velocity);

};


Ball.cpp
Code: [Select]
#include"Ball.h"
#include<SFML\Graphics.hpp>

Ball::Ball(sf::Image &Image){
BallSprite.SetImage(Image);
}

Ball::~Ball(){

}


Errors:
Code: [Select]
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(5): error C2275: 'sf::Vector2f' : illegal use of this type as an expression
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(5): error C2146: syntax error : missing ';' before identifier 'Velocity'
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(5): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(8): error C2275: 'sf::Image' : illegal use of this type as an expression
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(8): error C2146: syntax error : missing ')' before identifier 'Image'
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(8): error C2056: illegal expression
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.cpp(4): error C2511: 'Ball::Ball(sf::Image)' : overloaded member function not found in 'Ball'
1>          c:\users\alex\documents\visual studio 2010\projects\breakout\breakout\ball.h(3) : see declaration of 'Ball'


Any ideas why it doesn't like me trying to pass the Vector2f and the Image? The error on Vector2f really confuses me.
Title: Passing sprites, images and other things?
Post by: Laurent on July 26, 2011, 07:46:32 am
Private and Public should be lower case -- C++ is case sensitive.