Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Using sprite problem.  (Read 3445 times)

0 Members and 1 Guest are viewing this topic.

orgos

  • Newbie
  • *
  • Posts: 27
    • View Profile
Using sprite problem.
« on: June 09, 2009, 04:32:13 pm »
Hello I'm new here.

Im using Code:Blocks on windows with lastest SFML. I testing and triying the tutorials expamples.

I have a complire error is this:

Code: [Select]
||Info: resolving vtable for sf::Spriteby linking to __imp___ZTVN2sf6SpriteE |
main.cpp||variable 'vtable for sf::Sprite' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.|
main.cpp||variable 'vtable for sf::Sprite' can't be auto-imported. Please read the documentation for ld's --enable-auto-import for details.|
||=== Build finished: 2 errors, 0 warnings ===|



and the code is this:


Code: [Select]

#include <SFML/Graphics.hpp>



int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "My App");

    sf::Image image;

    if (!image.LoadFromFile("data/images/main.png"))
    {

    }

    sf::Sprite Sprite;
    Sprite.SetImage(image);

    Sprite.SetColor(sf::Color(0, 255, 255, 128));
    Sprite.SetPosition(200.f, 100.f);
    Sprite.SetScale(2.f, 2.f);



    // Start game loop
    while (App.IsOpened())
    {
        /// Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Get elapsed time
        float ElapsedTime = App.GetFrameTime();

        // Move the sprite
        if (App.GetInput().IsKeyDown(sf::Key::Left))  Sprite.Move(-100 * ElapsedTime, 0);
        if (App.GetInput().IsKeyDown(sf::Key::Right)) Sprite.Move( 100 * ElapsedTime, 0);
        if (App.GetInput().IsKeyDown(sf::Key::Up))    Sprite.Move(0, -100 * ElapsedTime);
        if (App.GetInput().IsKeyDown(sf::Key::Down))  Sprite.Move(0,  100 * ElapsedTime);

        // Rotate the sprite
        if (App.GetInput().IsKeyDown(sf::Key::Add))      Sprite.Rotate(- 100 * ElapsedTime);
        if (App.GetInput().IsKeyDown(sf::Key::Subtract)) Sprite.Rotate(+ 100 * ElapsedTime);

        // Clear screen
        App.Clear();

        // Display sprite in our window
        App.Draw(Sprite);

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}




Can any one help me ?

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Using sprite problem.
« Reply #1 on: June 09, 2009, 04:48:27 pm »
It sounds like you're linking it wrong.  Are you using the dynamic or the static version of the library?

Also there might be a problem in your code in that you are moving the sprite before it is cleared.  It might work as written but it is better to have code running in the main processor while the blitter is clearing the screen for the next draw.

orgos

  • Newbie
  • *
  • Posts: 27
    • View Profile
Using sprite problem.
« Reply #2 on: June 09, 2009, 05:02:13 pm »
I found the problem i not put the SFML_DYNAMIC on the #defines configuration.

If the code have problem so the tutorials code have problem too, because I copy and paste the code to test it, thanks for the help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Using sprite problem.
« Reply #3 on: June 09, 2009, 05:13:18 pm »
Quote
If the code have problem so the tutorials code have problem too, because I copy and paste the code to test it, thanks for the help.

The code is ok, you just didn't setup your project properly to use the dynamic libraries. You should have read the "getting started" tutorial before actually getting started.
Laurent Gomila - SFML developer