1
General / Delay using Clock
« on: May 08, 2011, 11:49:23 am »
Hey everybody
I've finished my game (almost) and I have one obstacle left. Now if i can fix this everything will work as it is the key to my spawn engine. The goal is to add a ring sprite to the vector every time the clock reaches the delay time constant.
First part at the top of main():
Second part whilst App is running and player alive:
Can you see what's going wrong? Xcode produces no errors and I've followed everything in the tutorial.
I've finished my game (almost) and I have one obstacle left. Now if i can fix this everything will work as it is the key to my spawn engine. The goal is to add a ring sprite to the vector every time the clock reaches the delay time constant.
First part at the top of main():
Code: [Select]
// Initialise counter for ring spawn delay
sf::Clock Clock;
float Time = Clock.GetElapsedTime();
Clock.Reset();
Second part whilst App is running and player alive:
Code: [Select]
// Spawn Rings
if (Time == DELAY_TIME)
{
// Add ring sprite to the ringSpawn vector
ringVec.push_back(Ring);
// Give that ring a random y co ordiante
spawnIterator->SetX(0);
spawnIterator->SetY(rand_Y);
// Increment iterator
spawnIterator++;
// Reset the clock
Clock.Reset();
}
Can you see what's going wrong? Xcode produces no errors and I've followed everything in the tutorial.