我们可以把精灵的SFML / C ++数组? [英] Can we make an array of sprites in SFML/C++?
本文介绍了我们可以把精灵的SFML / C ++数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题很简单。我们可以在SFML精灵或图像组成的数组。例如:
My question is very simple. Can we make an array of sprites or images in SFML. For example:
int myArray[] = {1, 2, 3};
考虑索引号的一个,两个和三个三种不同的图像。
我们该怎么办呢?任何人都可以用一些code例子解释一下吗?
Consider index number one, two and three are three different images. How can we do it? Can anyone explain with some code example?
推荐答案
尝试
std::vector<sf::Sprite> myArray;
或
sf::Sprite myArray[3];
检查出这个答案<一个href=\"http://stackoverflow.com/questions/15259771/sfml-2-0-having-the-same-sprite-looped/15259865#15259865\">question.其主要部分是:
Check out the answer of this question. The main part is:
// Create a texture
sf::Texture invaderTexture;
// Load image file into that texture
invaderTexture.loadFromFile("images/invaders.png");
// Create a vector of 10 sprites initialised with the texture above
std::vector<sf::Sprite> invaderSprites(10, sf::Sprite(invaderTexture));
这篇关于我们可以把精灵的SFML / C ++数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文