sprite-kit

Game Scene cannot be constructed because it has not accessible initializers

旧街凉风 提交于 2019-12-24 14:32:25
问题 Xcode is dropping an error and I dont know how to solve it. Maybe someone can give me a hand or a good hint? Here is my code that is working within my Game Scene: var currentLevel: Int = 1 var platforms: PlatformsNode! var platformNode1: PlatformNode! var platformNode2: PlatformNode! var platformNode3: PlatformNode! var platformArray = [SKNode]() let passenger = SKSpriteNode(imageNamed: "passenger") var passengerNumber:Int = 1 var startPlatform = [3, 3, 2, 1, 2] var destinationPlatform = [1,

Failed to load a scene from an sks file

北慕城南 提交于 2019-12-24 14:28:39
问题 I have a sks file containing a scene (GameScene class), and I implemented initWithCoder: in GameScene. I'm trying to load the scene in the controller this way: let file = NSBundle.mainBundle().pathForResource("GameScene", ofType: "sks")! if let scene = NSKeyedUnarchiver.unarchiveObjectWithFile(file) as? GameScene {...} But the block is never executed and initWithCoder: is never called. 来源: https://stackoverflow.com/questions/35234887/failed-to-load-a-scene-from-an-sks-file

applyForce is not smooth

不想你离开。 提交于 2019-12-24 14:16:55
问题 Hopefully someone can help. I have been pulling my hair out on this one! Below is some of the control pad code from my Sprite Kit game which uses applyForce to move the hero ship. I like how the controls and movement feel, its got some nice drift, etc... However I have inconsistent results on the animation/movement it produces. Sometimes (about half the time) the animation is perfectly smooth and looks correct. The rest of the time the ship movement animation stutters at different intensities

show GKGameCenterViewController in SKScene

六月ゝ 毕业季﹏ 提交于 2019-12-24 14:15:32
问题 I struggling with the following Problem: I've made a game with SpriteKit. I implemented the GameCenter to my game. It works. Player logs in automatically and the highscore will be added to the default Leaderboard. But for example in the "EndScreen" I want to show the GameCenterLeaderboard . Appledocumentation tells me that I should use the following code: - (void) showGameCenter { GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init]; if

WorldNode conflicting with object spawning

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 13:46:04
问题 This question is in reference to this one: Object positioning is off so I implemented the code again: let xAxisSpawnLocations: [CGFloat] = { var spawnLocations:[CGFloat] = [] //Create 5 possible spawn locations let numberOfNodes = 5 for i in 0...numberOfNodes - 1 { /* Spacing between nodes will change if: 1) number of nodes is changed, 2) screen width is changed, 3) node's size is changed. */ var xPosition = (frame.maxX - player.size.width) / CGFloat((numberOfNodes - 1)) * CGFloat(i) //add a

Move two paddles at same time in SpriteKit + Swift

二次信任 提交于 2019-12-24 13:35:37
问题 I am making a simple Pong game using SpriteKit + Swift. It is a multiplayer game, so I want two people to be able to move the two paddles. I want to be able to move the paddles at the same time. When I run the code below, which is the touchesBegan function, I am only able to move each paddle when one finger is pressing the display. When I try to touch another paddle, while my finger is already on the screen, it does not respond. let touch = touches.first as UITouch? let touchLocation = touch?

How to implement SKActionTimingFunction?

被刻印的时光 ゝ 提交于 2019-12-24 12:34:34
问题 How do you implement SKActionTimingFunction in objective-c?. I've looked everywhere and I just found an example in swift. Thanks! 回答1: heres an example moveAction.timingFunction = ^float(float t){ return sin(t * M_PI/2); }; man i hate blocks in objective-c 回答2: In Swift 4.2: moveAction.timingFunction = { time -> Float in return sin(time * .pi/2) } 来源: https://stackoverflow.com/questions/28520521/how-to-implement-skactiontimingfunction

Detect and ignore touches on iAd banners

别来无恙 提交于 2019-12-24 12:33:50
问题 I have a Sprite Kit game that first displays a menu screen. The game starts when you tap anywhere on the screen. I am displaying iAd's. The problem I have is when a user taps the iAd banner to view the add, GameScene is responding to the tap and starting the game. Ideally I want to detect that the touch was on the iAd banner and not start the game in this case. GameScene.m -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { // I dont want to start game if the touch was on the

adding uitextfield or (textentry box with keyboard) in sprite kit

只愿长相守 提交于 2019-12-24 11:36:45
问题 I am recently working on sprite kit to create a simple game where user input name as identity and moves forward to play game and has option to edit name or replace name. Which is best option to use uitextfield : in skscene or viewcontroller ? Or any other solutions? I had tried with uitextfield adding in skscene but got memory issue (since i called scene from viewwilllayoutSubview override func viewWillLayoutSubviews() { let skView = self.view as! SKView skView.ignoresSiblingOrder = true let

iAD View Freezes On Ad Close

半城伤御伤魂 提交于 2019-12-24 11:35:53
问题 Ok, so after testing on the simulators it turns out that this issue is only occurring on actual devices ... How would I fix this? I am making an iOS app with SpriteKit and am implementing iAD. Everything works more or less like I expect it too, except for one thing. When I tap on the ad, it brings me to a full screen ad, as expected, but when I close that ad the current view freezes, as in nothing happens visually. I know the app is still running because when I click the banner ad again and