sprite-kit

Interstitial iAds in SpriteKit?

☆樱花仙子☆ 提交于 2020-01-06 19:28:54
问题 I'm using SpriteKit for my iOS app, and need some full-screen (or sometimes called "interstitial" iAds to pop up every so often. I can figure out the code for when it happens, but I need to know how to add iAds without necessarily changing the View Controller. I tried a [tutorial][1] by Techotopia on Interstitial iAds, but to do it I need to transition between actual View Controllers. Well, I tried this, but whenever transitioning back from the iAd view controller to the GameViewController,

Make explosion animation SKaction and remove

最后都变了- 提交于 2020-01-06 18:41:21
问题 I want to make a animation to my game when two sprite nodes have a collision. So i create this function : func contactEntreMeteorites(Meteorites : SKSpriteNode , Meteorites2 : SKSpriteNode){ Meteorites.removeFromParent() Meteorites2.removeFromParent() let ExplosionTexture1 = SKTexture(imageNamed: "Explosion1.png") let ExplosionTexture2 = SKTexture(imageNamed: "Explosion2.png") let ExplosionTexture3 = SKTexture(imageNamed: "Explosion3.png") let ExplosionTexture4 = SKTexture(imageNamed:

Make explosion animation SKaction and remove

我的未来我决定 提交于 2020-01-06 18:41:11
问题 I want to make a animation to my game when two sprite nodes have a collision. So i create this function : func contactEntreMeteorites(Meteorites : SKSpriteNode , Meteorites2 : SKSpriteNode){ Meteorites.removeFromParent() Meteorites2.removeFromParent() let ExplosionTexture1 = SKTexture(imageNamed: "Explosion1.png") let ExplosionTexture2 = SKTexture(imageNamed: "Explosion2.png") let ExplosionTexture3 = SKTexture(imageNamed: "Explosion3.png") let ExplosionTexture4 = SKTexture(imageNamed:

How to choose a random SKShapeNode from an array using arc4random?

◇◆丶佛笑我妖孽 提交于 2020-01-06 15:43:14
问题 I am trying to make my first app using sprite kit and swift. I have created an array and populated it with two shape nodes (shown below. //name the properties for enemy 1 enemy1 = SKShapeNode (rectOfSize: CGSize(width: rectWidth/10, height: rectHeight/10)) enemy1.position = first enemy1.fillColor = UIColor.blackColor() enemy1.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: rectWidth, height: rectHeight)) enemy1.physicsBody?.dynamic = true enemy1.physicsBody?.affectedByGravity =

SKAction.moveToX repeat with value change

女生的网名这么多〃 提交于 2020-01-06 15:17:47
问题 i want to be able move the ball with pause every 20 pixels moved i tried this one but didn't do nothing, the ball stays at the point where it started it doesn't move to the end of the screen,i know i didn't put the waitForDuration , because i wanted to check if it will move or not func spwan() { let ball:SKSpriteNode = SKScene(fileNamed: "Ball")?.childNodeWithName("ball") as! SKSpriteNode ball.removeFromParent() self.addChild(ball) ball.name = "spriteToTrack" ball.zPosition = 0 ball.position

Detecting shakes in sprite kit

感情迁移 提交于 2020-01-06 14:56:30
问题 I have a problem with detecting a shake. It's a skscene in the Sprit Kit and I defined the motion detector like this: - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{ } -(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"test?"); } Where is my mistake? Do I have to implement it like I had to do it with the UIGestureRecognizer? Thanks in advance (and sorry for my bad english) Julian 回答1: Apparently, you can't detect shake events from a SKScene

Invisible circle stroke color in SKSpriteNode (iOS)

笑着哭i 提交于 2020-01-06 08:26:03
问题 I'm trying to paint the stroke color in black, but it doesn't appear any line... This is how it's displayed in the iOS simulator: BUT, if I run the same code in the Xcode playground, the circle is perfect My scene code: import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Setup your scene here */ self.backgroundColor = UIColor.whiteColor() let midcir = self.mainCircle() self.addChild(midcir) } func mainCircle()->SKSpriteNode{ let node = SKSpriteNode()

sort a SKSpriteNode array according to a specific element

流过昼夜 提交于 2020-01-05 21:17:20
问题 I have a SKSpriteNode array declared like this : class rgbNodes: SKSpriteNode { } var colorNode = [rgbNodes]() colorNode.append(rgbNodes(imageNamed: "Rectangle")) // every time we want to add a new element to this array And I would like to sort every element of this array according to their position.x value, for example, if : colorNode[0].position.x = 25 colorNode[1].position.x = 5 colorNode[2].position.x = 15 I want the array to be sorted like this : colorNode[0].position.x = 5 colorNode[1]

How do I do consecutive function calls using the completion handler in Swift on an SKSpriteNode?

眉间皱痕 提交于 2020-01-05 15:42:07
问题 I am trying to get three functions to call, one after the other after each has completed a specific number of loops. I have succeeded in trying to call a second function once a first function with a count has completed. I am struggling to do a third, fourth, etc. The problem I appear to have is in the syntax for the call in the view did load: midGroundlevelMovingSlow(midGroundlevelMovingMedium(midGroundlevelMovingFast())) Does not work for the three functions where as:

SKAction go to and stop at a specific frame

戏子无情 提交于 2020-01-05 08:50:11
问题 Flash has gotoAndPlay() and gotoAndStop() methods for movie clips to skip to any frame. I don't see any methods in SKAction class but is there a way or workaround to simulate this for SKAction instances? EDIT: Additional info on gotoAndPlay and gotoAndStop: gotoAndPlay(n) brings the playhead to the nth frame. If the clip is 30 frames long and you call gotoAndPlay(15) you start playing from the 15th frame and stop at 30. gotoAndStop(n) takes the animation to the nth frame and stops there