   Moving sprite from class
  I have a sprite that renders and the fucntions I have set up to make retrieve the X/Y pos of the class seem to work somtimes but they are not working when I use a key event to change their respective valuesThis is my class:class Submarine {private: int subPosX; int subPosY;bool powerEmpty;int power;int distance;public:int setdistance(int);void setX(int x) { subPosX = x; }void setY(int y){subPosY = y;}int GetX(){return subPosX;}int GetY(){return subPosY;}void setXY(int, int){subPosX;subPosY;}This is what I am using to change the values:if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Left)){//playerSub.Move(-3.0,0);Lead.setXY(-50.0,0.0);cout<<"the x val is "<<Lead.GetX();cout<<"the y val is "<<Lead.GetY(); }The above code does not move the sprite and the cout value doesnt chage either :S   
Quote:Original post by g_m_tvoid setXY(int, int){subPosX;subPosY;}If this is a copy & paste from the actual code, then this function does nothing at all and thus calling this won't move the sprite.You should change it so something like:void setXY(int x, int y){    setX(x);    setY(y);};  What does your program look like?   ;  ok I have tried the function:void setXY(int x, int y){subPosX = x;subPosY = y;}and tried calling withLead.setXY(-5,0);but still nothing, now I am thinking that I should create a method to change the subposX and subposY.i will be a few mins when i get a problme i will post in this thread as I am still trying to make the sprite move with the x/y from the classthanks to everyone who replied   ;Quote:Original post by _fastcallWhat does your program look like?;  in a previous thread i was advised against putting up all my code, so if you tell me what bit you would like? sorry if I seem difficult but I dont want to break any rules.   ;Quote:Original post by g_m_tbut still nothing, now I am thinking that I should create a method to change the subposX and subposY.Did you check what's actually happening with a debugger? How are you retrieving subposX and subposY when you're rendering the sprite?Oh, and please surround code with [source] tags (or [code] tags for small pieces of code). They preserve formatting and source tags add some basic syntax highlighting.As for putting up all code, that's indeed not advisable (or necessary), but do post code that is relevant to your problem. In this case, the class itself and the code that uses the class (e.g. the code that sets and reads the position).   ;  in regards to creating a method I havent gotten very far, but this should help you guys understand what I am trying to do. At the moment I create an instance of my Submarine class called 'Lead' then I set x and y using:static int x;static int y;//SubmarineSubmarine Lead;Lead.setX(150);Lead.setY(300);after this i get x and y like this:x = Lead.GetX();y = Lead.GetY();the x and y from the 'Lead' tell the program where the sprite should be you'll see x and y in the following line of code.// Sub sf::Sprite playerSub(subSprite,Vector2f(x,y),Vector2f(2,2),0,Color(255,255,255,255));This is my classclass Submarine {private: int subPosX; int subPosY;bool powerEmpty;int power;//void subUP();int distance;public:int setdistance(int);void setX(int x) { subPosX = x; }void setY(int y){subPosY = y;}int GetX(){return subPosX;}int GetY(){return subPosY;}void setXY(int x, int y){subPosX = x;subPosY = y;}Now when I try to change subPosX i use:if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Left)){//playerSub.Move(-3.0,0);Lead.setX(Lead.GetX()-50);cout<<"the x val is "<<Lead.GetX();cout<<"the y val is "<<Lead.GetY(); }every time i tap the left key it couts the x and y value and the x value actually lowers, but the sub doesnt move. I need it to update from the 'Lead'hope this helped you to understand I look forward to your help =]   ;  Looks like you're correctly initializing the sprite at the sub's position, but from there on, you're never updating the sprite position - only the sub's position.   ;  Do you know how I can update it?although I have a sneaking suspicion that I may have to incorporate the sf class in to my own...   