sprite-kit

Obstacles With GameplayKit

喜夏-厌秋 提交于 2019-12-24 06:48:25
问题 Here is my question: How can I convert an SKSpriteNode array into an array of GKObstacles so that an agent can appropriately avoid these obstacles by using the goalToAvoidObstacles:(nonnull NSArray<GKObstacle *> *) maxPredictionTime:(NSTimeInterval) /? It seems that the way in which I am creating the GKObstacle array is not allowing the GKGoal to identify these as obstacles correctly, no matter what weight I give to the goal. I have currently several SKNode s that are added to an SKScene

Change texture with random

我们两清 提交于 2019-12-24 06:44:06
问题 I have some textures var texturesOfEnemies = [SKTexture(imageNamed: "EnemyTexture1"), SKTexture(imageNamed: "EnemyTexture2"), SKTexture(imageNamed: "EnemyTexture3"), SKTexture(imageNamed: "EnemyTexture4"), SKTexture(imageNamed: "EnemyTexture5")] I'm using arc4random to select a random texture var randomTextureOfEnemies = Int(arc4random_uniform(UInt32(texturesOfEnemies.count))) and assign the selected texture to a node by enemy.texture = texturesOfEnemies[randomTextureOfEnemies] I have some

Using AdMob interstitial ads in iOS game applications and Swift

六眼飞鱼酱① 提交于 2019-12-24 06:37:12
问题 Okay, I've spent days now doing this. I've gone through admob's tutorials, youtube, stack exchange, everything and I cannot find a solution to my problem. I'm trying to implement admob's interstitial ads into my iOS game application. The code compiles, builds, runs, the game is played, but ads will not show up. This is my GameViewController.swift import UIKit import SpriteKit import GoogleMobileAds class GameViewController: UIViewController, GADInterstitialDelegate { //AD STUFF---------------

How to change text of a SKLabelNode?

倖福魔咒の 提交于 2019-12-24 06:06:08
问题 How do I update a label's text that was created in initWithSize? Here is the code for the label within the initWithSize: SKLabelNode *scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"TimesNewRoman"]; scoreLabel.text = [NSString stringWithFormat:@"%i", score]; scoreLabel.fontSize = 30; scoreLabel.position = CGPointMake(290, CGRectGetMidY(self.frame) - 30); scoreLabel.zRotation = -M_PI/2; [self addChild:scoreLabel]; As the game is running I update the variable score and I was just wondering

SKLightNode not working on real device [iPhone 5]

旧街凉风 提交于 2019-12-24 05:37:38
问题 I've set up a minimalistic project here which simply adds a red square and - after tapping the screen - a light source lighting it. On simulator it runs fine, but on my iPhone 5 the square just becomes invisible as soon as the light source gets added to the node tree. Can anyone test this on other, real devices and give feedback? Any solutions? It's driving me crazy. Here's the scene's code: SKLightNode* lightNode; @implementation GameScene -(void)didMoveToView:(SKView *)view { //Add some

Is the order of SKNode.nodesAtPoint guaranteed?

旧时模样 提交于 2019-12-24 05:04:30
问题 SKNode has a method nodesAtPoint which returns an array of children nodes that intersect given point. Is the order of the elements in such array deterministic (e.g. by drawing order)? I could not find an answer in documentation, so probably the answer is "no", but I would like to verify. 回答1: Nope, Sprite Kit does not take into account z-position when traversing the node-tree (definitely for performance reasons). You can easily see this by adding a few nodes to a scene in-order and then

Swift 1.2 bug: different behavior between iOS 7.1 and 8.3 while removing SKSpriteNode from parent

China☆狼群 提交于 2019-12-24 04:04:35
问题 Sample project: https://github.com/wilkinho/RemoveFromParentTest Swift version: 1.2 Xcode version: 6.3 I try to remove a SKSpriteNode from its parent and add it back to the SKScene within its own SKAction run block (or callback). The result differs in iOS 7.1 and 8.3. In iOS 7.1, after touching the device, the console prints: sprite.parent:Optional(<SKScene> name:'(null)' frame:{{0, 0}, {320, 568}}) sprite.scene:nil sprite2.parent:Optional(<SKScene> name:'(null)' frame:{{0, 0}, {320, 568}})

Sprite Kit - Low Resolution Texture on Retina when using textureFromNode

眉间皱痕 提交于 2019-12-24 03:42:08
问题 For my game I am trying to create custom textures from two other textures. This is to allow for a varietly of colours, etc in my sprites. To do this, I'm creating a sprite by adding both textures together, then applying this to a new SKTexture by using SKTexture *texture = [self.view textureFromNode:newSprite]; This works great on the whole and I get a nice custom texture. Except when trying my game on Retina devices, where the texture is the correct size on the screen, but clearly a lower

My app crashes because of unfinished sounds in my sprite-kit game

僤鯓⒐⒋嵵緔 提交于 2019-12-24 03:20:58
问题 Can't understand why my app crashes always going background when a sound is playing. If no sound here app won't crash. I have a SKAction which plays a sound. I preload this songs with static let in Actions class and call static func which returns SKAction with sound. So I have completion level sound. When it plays, I hit home button, them come back to app. There app crashes with message "Thread 1: EXC_BAD_ACCESS(code=1, adress=0xff8e9abc)". Has anybody an idea what's going on here? This is my

Get visible location of SpriteKit node after parent rotation

▼魔方 西西 提交于 2019-12-24 03:12:24
问题 I am using Sprite Kit (uh, perhaps "learning" is more apropos). I have a square game board: +-----+-----+-----+ | 0,2 | 1,2 | 2,2 | +-----+-----+-----+ | 0,1 | 1,1 | 2,1 | +-----+-----+-----+ | 0,0 | 1,0 | 2,0 | +-----+-----+-----+ During testing I am adding a sprite to board position 2,0. I then rotate the board 90 degrees counter-clockwise leaving the sprite - visually - in position 2,2. Of course, since the position of sprites aren't modified by rotation the actual x,y coords don't change.