2014-01-05 22 views
1

我的問題很簡單。我們可以在SFML中製作一組精靈或圖像。例如:我們可以在SFML/C++中製作一個精靈數組嗎?

int myArray[] = {1, 2, 3}; 

考慮索引號一,二和三是三個不同的圖像。 我們該怎麼做?任何人都可以解釋一些代碼示例?

+0

可能重複(http://stackoverflow.com/questions/20932939/can-we-make-陣列或 - 多維陣列-的-精靈合SFML-2-1-c)的 – AlexxanderX

回答

2

嘗試

std::vector<sf::Sprite> myArray; 

sf::Sprite myArray[3]; 

看看這個question的答案。其主要部分是:

// 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 2.1/C++]
相關問題