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

Pages: [1]
1
Graphics / change IntRect in Sprites image
« on: January 09, 2011, 01:58:22 pm »
i feel ashmed  :oops:
such mistake .
thx a lot Laurent :D

2
Graphics / change IntRect in Sprites image
« on: January 09, 2011, 01:50:57 pm »
Hello guys,

i have a problem with my Spritesheet, so i want some kind of hints or something else. :)

I have use the SuFu but doesn't found anything that helps.

here is my code :

Code: [Select]

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <vector>

int main(){

sf::Sprite sprite_;
sf::Image image_;
sf::RenderWindow App(sf::VideoMode(800,600,32),"RUN FOREST RUN !!! ");


if(!image_.LoadFromFile("char.png"))
return EXIT_FAILURE;
sprite_.SetImage(image_);
sprite_.SetPosition(200.f,200.f);
sprite_.SetSubRect(sf::IntRect(0,0,25,35));


while(App.IsOpened())
{

float ElapsedTime =  App.GetFrameTime();
if(App.GetInput().IsKeyDown(sf::Key::Up))
{

sprite_.SetSubRect(sf::IntRect(0,25,25,50));
sprite_.Move(50.f,50.f);



}

if(App.GetInput().IsKeyDown(sf::Key::Down)){


sprite_.SetSubRect(sf::IntRect(0,105,25,140));
sprite_.Move(100.f,100.f);

}

if(App.GetInput().IsKeyDown(sf::Key::Left)){


sprite_.SetSubRect(sf::IntRect(0,70,25,105));
sprite_.Move(150.f,150.f);
}

if(App.GetInput().IsKeyDown(sf::Key::Right)){


sprite_.SetSubRect(sf::IntRect(0,140,25,175));
sprite_.Move(200.f,200.f);
}

App.Clear();
App.Draw(sprite_);
App.Display();


}


return EXIT_SUCCESS;
}




I have tried to Load the image new, reset the IntRect, the result was, that i get a sprite on my screen, but he doesn't move.
The only thing that helps was to push_back all Sprites in a vector and go through this.
Is there some other way?
Some hints would be enough =)

Pages: [1]