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 - Tex Killer

Pages: 1 ... 12 13 [14] 15 16 17
196
Graphics / Error with calling sf::Sprite
« on: December 18, 2011, 08:51:42 pm »
You need the first solution that I've sugested earlier.
Like this:

Code: [Select]

sf::Sprite* Title;
int LoadMedia();
int Menu(sf::Sprite*);
int Game();

int LoadMedia() {
    sf::Image* ITitle = new sf::Image();
    if(!ITitle->LoadFromFile("media/images/UI/title.png")) {return EXIT_FAILURE;}

    Title = new sf::Sprite(ITitle);
    Title->SetCenter(221,51.5);
}

int Menu () {
    Title->SetPosition(Menu.GetWidth()/2,100);
}

int Game() {
//The usual stuff
}

int main() {
  LoadMedia();
  Menu();
  Game();

  return EXIT_SUCCESS;
}


You wont even need to pass them as parameters, as they'll be global.

197
Graphics / Re: Error with calling sf::Sprite
« on: December 18, 2011, 07:58:49 pm »
Code: [Select]

sf::Sprite* LoadMedia();
int Menu(sf::Sprite* Title);
int Game();

sf::Sprite* LoadMedia() {
    sf::Image* ITitle = new sf::Image();
    if(!ITitle->LoadFromFile("media/images/UI/title.png")) {return EXIT_FAILURE;}

    sf::Sprite* Title = new sf::Sprite(ITitle);
    Title->SetCenter(221,51.5);
    return Title;
}

int Menu (sf::Sprite* Title) {
    Title->SetPosition(Menu.GetWidth()/2,100);
}

int Game() {
//The usual stuff
}

int main() {
  sf::Sprite* Title = LoadMedia();
  Menu(Title);
  Game();

  return EXIT_SUCCESS;
}

198
Graphics / Error with calling sf::Sprite
« on: December 18, 2011, 07:19:38 pm »
Your Title variable is local to LoadMedia, so after it is executed Title gets destroyed. You can make it global, or you can return it to the main function. If you choose to return it to main, you must use dynamic allocation... making a pointer and constructing it with new.

199
Graphics / bullet keep following mouse direction
« on: December 18, 2011, 07:16:17 pm »
Code: [Select]
class MySprite {
    public:
        sf::Sprite sprite;
        float speedX;
        float speedY;
}


And then:

Code: [Select]
MySprite Sprite;
Sprite.speedX = [your calculations here];
Sprite.speedY = [your calculations here];
// ...
Sprite.sprite.Move(Sprite.speedX * Speed, Sprite.speedY * Speed);


You would probably have better ways of doing it, depending on your code design. Test it and make it yourself.

200
General / SFML Window not showing!!!
« on: December 18, 2011, 03:28:24 am »
Just using SFML2 should be enough, I think.

201
Window / sfml-window-d.dll is missing from my computer
« on: December 18, 2011, 03:27:16 am »
Anything could cause this crash. You could use the debug to find where it crashes.

202
General / SFML Window not showing!!!
« on: December 18, 2011, 01:30:21 am »
Viruses, might not help, but do you use an ATI card? SFML 1.6 did have a problem with those cards.

203
Window / sfml-window-d.dll is missing from my computer
« on: December 18, 2011, 01:22:31 am »
It is possible that the IDE is using the project folder as current directory, and not the folder where the executable is on.

204
Graphics / bullet keep following mouse direction
« on: December 18, 2011, 01:19:30 am »
You must store it on your own, out of the Sprite class, and use it from wherever you've stored. You can make a container class, that have a Sprite inside, and this vector as well.

205
Graphics / Is there a function that clears a specific sprite
« on: December 18, 2011, 01:16:51 am »
Chocolatesheep, enable vertical sync:

Code: [Select]
window.UseVerticalSync(true);

206
Graphics / AniSprite Error
« on: December 11, 2011, 08:01:06 am »
Change
Code: [Select]
sf::IntRect AniSprite::GetFramePosition(int frame);
to
Code: [Select]
sf::IntRect GetFramePosition(int frame);
on the header file.

207
Graphics / AniSprite Error
« on: December 11, 2011, 04:17:36 am »
You have not included "AniSprite.h" on the main file.

208
General / Avoid Repeating Input-Events
« on: December 09, 2011, 09:12:31 pm »
The Input only gets updated when you pull for events.
You should make your loop pull for events, but that would cause your graphics to be frozen until you release the Down key. The best thing to do is move only 1 time per game frame.

209
Graphics / how to load sprite sheet? new to sfml.
« on: December 09, 2011, 10:27:27 am »
You should also use another type of image, as JPEG will produce some garbage on the image and the mask will not work very well.

210
Graphics / how to load sprite sheet? new to sfml.
« on: December 09, 2011, 10:15:01 am »
Quote from: "mnajrg"
The whole image loads on the window..


If you don't set the SubRect of the sprite you are printing, the whole image should load on the window. You must set it to the portion of the image you want to show.

By the way, your code contains a call to Draw() without parameters. I don't think that would compile.

Edit: Laurent was faster xD

Pages: 1 ... 12 13 [14] 15 16 17