Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Richard Rodriguez
2,687 PointsSpriteKit : Easy question but how do I spawn different nodes at different times?
I used the SpaceCat update method as a foundation. Basically right now the Space dogs and the coins are being randomly added to the scene every 1.5 sec.
Is there a way to delay the time the coins are added?
how can i implement something similar to a SKAction waitForDuration: .5] completion:^{ so that the coins will spawn at a delayed time after the space dogs. I don't want them appearing at the same time .....
-(void) update:(NSTimeInterval)currentTime {
if (self.lastUpdateTimeInterval) {
self.timeSinceSpaceDogAdded += currentTime -self.lastUpdateTimeInterval;
self.totalGameTime += currentTime - self.lastUpdateTimeInterval;
}
if (self.timeSinceSpaceDogAdded > self.addSpaceDogTimeInterval && !self.gameOver) {
[self addSpaceDog];
[self addCoins];
self.timeSinceSpaceDogAdded = 0;
}
self.lastUpdateTimeInterval = currentTime;
if (self.totalGameTime > 60) {
self.addSpaceDogTimeInterval= 1.5;
}else if (self.totalGameTime >45 ) {
self.addSpaceDogTimeInterval= 1.5;
}else if (self.totalGameTime >30 ) {
self.addSpaceDogTimeInterval= 1,5;
}else if (self.totalGameTime >2) {
self.addSpaceDogTimeInterval= 1.5;
}
1 Answer
Amit Bijlani
Treehouse Guest TeacherJust as you have self.timeSinceSpaceDogAdded > self.addSpaceDogTimeInterval you can create one for the coins: self.timeSinceCoinsAdded > self.addCoinsTimeInterval