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

Author Topic: Static Image and Sprite doesnt work in class  (Read 2044 times)

0 Members and 1 Guest are viewing this topic.

reDo

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Static Image and Sprite doesnt work in class
« on: April 28, 2011, 02:52:01 pm »
I have this code, but when I try to compile it, it says, please can somebody helps me? please a lot  :cry:  :roll:
code
Code: [Select]
/*
 * File:   Bullet.hpp
 * Author: Adamv
 *
 * Created on April 25, 2011, 6:11 PM
 */

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

#ifndef BULLET_HPP
#define BULLET_HPP

#define PI 3.14159265

class cBullet
{
        private:
            static sf::Image imgBullet;
            static sf::Sprite sprBullet;
            bool active;
            float x;
            float y;
            float angle;
            float distance;
           
        public:
            cBullet();
            bool IsActive();
            void SetActive(bool status, float mx, float my);
            void Move();
            void SetAngle(float mangle);
            void Draw(sf::RenderWindow & App);
            ~cBullet() {} ;
};

#endif /* BULLET_HPP */


errors
Code: [Select]
"/bin/make" -f nbproject/Makefile-Release.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Documents and Settings/Adamv/Desktop/CombatShooter'
"/bin/make"  -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/combatshooter.exe
make[2]: Entering directory `/c/Documents and Settings/Adamv/Desktop/CombatShooter'
mkdir -p build/Release/MinGW-Windows
rm -f build/Release/MinGW-Windows/main.o.d
g++.exe    -c -O2 -I/F/CodeBlocks/SFML-1.6-sdk-windows-mingw/SFML-1.6/include -MMD -MP -MF build/Release/MinGW-Windows/main.o.d -o build/Release/MinGW-Windows/main.o main.cpp
mkdir -p build/Release/MinGW-Windows
rm -f build/Release/MinGW-Windows/Bullet.o.d
g++.exe    -c -O2 -I/F/CodeBlocks/SFML-1.6-sdk-windows-mingw/SFML-1.6/include -MMD -MP -MF build/Release/MinGW-Windows/Bullet.o.d -o build/Release/MinGW-Windows/Bullet.o Bullet.cpp
mkdir -p dist/Release/MinGW-Windows
g++.exe     -o dist/Release/MinGW-Windows/combatshooter build/Release/MinGW-Windows/main.o build/Release/MinGW-Windows/Bullet.o -L/F/CodeBlocks/SFML-1.6-sdk-windows-mingw/SFML-1.6/lib /F/CodeBlocks/SFML-1.6-sdk-windows-mingw/SFML-1.6/lib/libsfml-graphics.a /F/CodeBlocks/SFML-1.6-sdk-windows-mingw/SFML-1.6/lib/libsfml-window.a /F/CodeBlocks/SFML-1.6-sdk-windows-mingw/SFML-1.6/lib/libsfml-system.a
f:/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x110): undefined reference to `cBullet::sprBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x132): undefined reference to `cBullet::sprBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x14a): undefined reference to `cBullet::sprBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x1d2): undefined reference to `cBullet::imgBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x213): undefined reference to `cBullet::imgBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x227): undefined reference to `cBullet::imgBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x22e): undefined reference to `cBulletInfo: resolving vtable for sf::Sprite by linking to __imp___ZTVN2sf6SpriteE (auto-import)
::sprBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x322): undefined reference to `cBullet::imgBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x363): undefined reference to `cBullet::imgBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x377): undefined reference to `cBullet::imgBullet'
build/Release/MinGW-Windows/Bullet.o:Bullet.cpp:(.text+0x37e): undefined reference to `cBullet::sprBullet'
collect2: ld returned 1 exit status
make[2]: *** [dist/Release/MinGW-Windows/combatshooter.exe] Error 1make[2]: Leaving directory `/c/Documents and Settings/Adamv/Desktop/CombatShooter'
make[1]: Leaving directory `/c/Documents and Settings/Adamv/Desktop/CombatShooter'

make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 4s)
 


but this is  not important because it says this in the past and it works
 
Code: [Select]
f:/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: warning: auto-importing has been activated without --enable-auto-import specified on the command line.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Static Image and Sprite doesnt work in class
« Reply #1 on: April 28, 2011, 02:57:31 pm »
The solution is well explained here:
http://tinyurl.com/3cy4h9s
Laurent Gomila - SFML developer

reDo

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Static Image and Sprite doesnt work in class
« Reply #2 on: April 28, 2011, 04:28:28 pm »
Oh thanks, I forgot  :mrgreen: