Rect Definition:
|
C-/C++-Quelltext
|
1
|
Rect (T LeftCoord, T TopCoord, T RightCoord, T BottomCoord)
|
Wieviele Spalten/Zeilen hat dein Bild, bzw in wieviele willst du es Teilen?
Was ist divid und factor?
Wie wärs mit (ungetestet):
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
|
int frameWidth = BildBreite / (Anzahl der Frames in X - Richtung); // Breite der Frame
int frameHeight = BildHoeche / (Anzahl der Frames in Y - Richtung); // Höche der Frame
int frameIndex = blabliblubb; // von Links Nach Rechts und von Oben nach Unten
int frameX = frameIndex % (Anzahl der Frames in X - Richtung); // X Index berechnen
int frameY = frameHeight / (Anzahl der Frames in X - Richtung); // Y Index berechnen
sf::IntRect EnemyRect((frameX *frameWidth), (frameY*frameHeight ), (frameX*frameWidth)+frameWidth, ((frameY*frameHeight)+frameHeight));
...
|
//Edit: Die Berechnung frameWidth bzw. frameHeight kannst du dir Sparen wenn du es Statisch machst und Gleich 50 setzten.
Mfg Rushh0ur