1
スプライトを描画すると、ウィンドウが閉じます。描画時のセグメンテーションエラー
私のコードでは のコードを外しておけばそれは間違いなく描画部分ですが、私のスプライトを描いている以外は問題ありません。実行しているとき
はまた、私はこのエラーを取得する:Segmentation fault (core dumped)
私はそれが何を意味するのか分からない:/を。
そして、ここに私のコードです:
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
//create vars
sf::Color bgColour(20, 175, 215);
vector<sf::Sprite> tiles;
void CreateTile(string Texture, int x, int y)
{
sf::Vector2f Pos(x, y);
sf::Texture Ftexture;
Ftexture.loadFromFile(Texture);
sf::Sprite Tile;
Tile.setTexture(Ftexture);
Tile.setPosition(Pos);
tiles.push_back(Tile);
}
int main()
{
//create window
sf::RenderWindow window(sf::VideoMode(800, 600), "-\\\\-(Game)-//-");
CreateTile("Recources/grass.png", 40, 40);
//main loop
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear(bgColour);
window.draw(tiles[1]);
window.display();
}
return 0;
}
ありがとう!