Private let greenDragonNode = SKSpriteNode(color. So you should append them to an array, and run them in a sequence, like this: import SpriteKit That is happening because only the last action from the for loop is executed. Let dragonNodeReturn = SKAction.move(to: dragonDestination2, duration: 3.0) Let dragonNodeTravel = SKAction.move(to:dragonDestination, duration: 3.0) Let dragonDestination2 = CGPoint(x: xDestination2, y: yDestination2) Let yDestination2 = CGFloat(arc4random()).truncatingRemainder(dividingBy: size.height) Let xDestination2 = CGFloat(arc4random()).truncatingRemainder(dividingBy: size.width) Let dragonDestination = CGPoint(x: xDestination, y: yDestination) Let yDestination = CGFloat(arc4random()).truncatingRemainder(dividingBy: size.height) Let xDestination = CGFloat(arc4random()).truncatingRemainder(dividingBy: size.width) Let dragonOrigin = CGPoint(x: xOrigin, y: yOrigin) Chinese dragon Illustration, Chinese dragon totem, black dragon illustration, dragon, chinese Style, cloud png. Dragon View, also known as Drakkhen II, is a frequently overlooked RPG for the SNES and the alleged prequel to the original Drakkhen. Let yOrigin = CGFloat(arc4random()).truncatingRemainder(dividingBy: size.height) Let xOrigin = CGFloat(arc4random()).truncatingRemainder(dividingBy: size.width) Private var lastUpdateTime : TimeInterval = 0 Private let greenDragonNode = GreenDragonSprite.newInstance() I tried the following code including labels to prove to myself that the random numbers are generating, at least up to 20. I think it might be because I'm not waiting for the action to complete before generating all of the random numbers. ![]() I can make the dragon appear at a random location and move once or twice but to make it continuously move from point to point and then move some more has given me trouble. I was trying to make a game where the dragon moves around randomly and the hero has to avoid it.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |