Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by Huehau ( 14 years ago )
#include <Thor/Animation.hpp>
#include <SFML/Graphics.hpp>

int main()
{
 sf::RenderWindow App(sf::VideoMode(800,600,32),"Animacja");
 App.setFramerateLimit(30);

 sf::Texture Texture;

 if(!Texture.loadFromFile&#40;"images/animka.png"&#41;)
 {
  return EXIT_FAILURE;
 }

 sf::Sprite sprite;
 thor::Animator animator;

 sprite.setPosition(100.f,100.f);

 thor::FrameAnimation::Ptr defaultAnim = thor::FrameAnimation::Create();
 defaultAnim->AddFrame(1.f, sf::IntRect(0,41,34,42));

 thor::FrameAnimation::Ptr walk = thor::FrameAnimation::Create();
 for(unsigned int i = 0; i < 3;i++)
 {
  walk->AddFrame(1.f,sf::IntRect(0,41*i,34,42));
 }

 animator.SetDefaultAnimation(defaultAnim,sf::seconds(1.f));
 animator.AddAnimation("walk",walk,sf::seconds(1.f));

 sf::Clock frameClock;

 while(App.isOpen())
 {
  sf::Event Event;
  while(App.pollEvent(Event))
  {
   if(Event.type == sf::Event::KeyPressed && Event.key.code == sf::Keyboard::Space)
   {
    
   }
  }

  animator.Update(frameClock.restart());
  animator.Animate(sprite);

  App.clear(sf::Color(255,255,255));
  App.draw(sprite);
  App.display();
 }

 return EXIT_SUCCESS;
}

 

Revise this Paste

Your Name: Code Language: