sprite-kit

Custom SKSpriteNode not detected during touch

纵然是瞬间 提交于 2019-12-18 02:41:38
问题 In learning SpriteKit, I am trying to make a small adventure game. I am creating a hero, and adding it to the scene, and then later, during touchesBegan: , I detect if the touch originated on the hero, and take actions accordingly. If I add the hero as a SKSpriteNode the touch detects him. If I add him as a subclass of SKSpriteNode the touch does not! The difference in adding: _heroNode = [SKSpriteNode spriteNodeWithImageNamed:@"hero.png"]; vs _heroNode = [[ADVHeroNode alloc] init]; The init

Storing game preferences and saved games in a secure format

落爺英雄遲暮 提交于 2019-12-18 01:20:23
问题 This is from Apple docs: When you design a game that reports scores to Game Center, you should also consider the security needs of your game. You want scores reported to Game Center to be an accurate accounting of how players are doing. Here are two suggestions: Store your game’s preferences and saved games in a secure format, rather than in clear text. If your game’s data is stored in clear text, a player can download the saved game data using iTunes, modify it, and resync it back to the

Storing game preferences and saved games in a secure format

做~自己de王妃 提交于 2019-12-18 01:20:09
问题 This is from Apple docs: When you design a game that reports scores to Game Center, you should also consider the security needs of your game. You want scores reported to Game Center to be an accurate accounting of how players are doing. Here are two suggestions: Store your game’s preferences and saved games in a secure format, rather than in clear text. If your game’s data is stored in clear text, a player can download the saved game data using iTunes, modify it, and resync it back to the

How does SKTexture caching and reuse work in SpriteKit?

冷暖自知 提交于 2019-12-17 23:46:54
问题 It is often mentioned on StackOverflow that SpriteKit does its own internal caching and reuse. Does Sprite Kit load a texture atlas multiple times if I use SKTextureAtlas later? should I cache textures in properties in sprite kit? SpriteKit memory management preload cached and fps issue If I don't make any effort to reuse textures or atlases, what caching and reuse behavior can I expect from SpriteKit? 回答1: Texture Caching in SpriteKit “Long story short: rely on Sprite Kit to do the right

What's the relationship between GameScene.swift and GameScene.sks files in SpriteKit template

◇◆丶佛笑我妖孽 提交于 2019-12-17 23:33:00
问题 I've been playing around with SpriteKit, and am getting a pretty decent feel about how to drive it from code, but am pretty baffled by the level editor included in Xcode 6. I've watched the wwdc videos ("platforms state of union" and "what's new in spriteKit"), and scrounged around the web, but haven't been able to find much description about the level editor, and what it's really doing. What I don't understand, is how are the two files that the template sets up related? Is the .sks file an

Sprite Kit Serious FPS Issue In Full Screen Mode on OS X

牧云@^-^@ 提交于 2019-12-17 23:25:08
问题 I'm making a fairly complex sprite kit game. I recently added support for OS X. I get 60 fps always, regardless of how my game is scaled when the window is resized (even when resized to max screen space). However, the moment I make my App enter "Full Screen," the fps drops to 30-40 fps and stays that way? But if I take my mouse cursor and reveal the menu bar while full screen is enabled, the fps goes back up to 60 fps! You can even test this bug by making a sprite kit game for mac in Xcode

How to keep SpriteKit scene paused when app becomes active?

风流意气都作罢 提交于 2019-12-17 21:28:36
问题 Is there anyway to prevent SpriteKit from automatically unpausing a scene when entering foreground/becoming active? I set paused = true and want it to remain so even when the app becomes active again after having been sent to the background. I should add that I'm doing this in swift, though I would not have expected the behaviour to be different in this regard. 回答1: Not sure if it is the same in objective C, but in swift I had to "override" a callback function that SKView calls behind the

Manually move node over a period of time

柔情痞子 提交于 2019-12-17 21:10:37
问题 I currently have the following functions declared which moves a node to a target location which is called in the update function of the scene (In this situation, I can't use SKAction.moveTo) func moveTowardsPosition(targetPosition: CGPoint, withTimeInterval timeInterval: NSTimeInterval) { let currentPosition = self.position var deltaX = targetPosition.x - currentPosition.x var deltaY = targetPosition.y - currentPosition.y var maximumDistance = 3 * CGFloat(timeInterval) moveFromCurrentPosition

How to make physics bodies stick to nodes anchor points

…衆ロ難τιáo~ 提交于 2019-12-17 20:29:54
问题 I have four squares in the middle of my scene set up with various anchor points. When tapped, they move together and come apart depending on what position: func rotate(angle : CGFloat, animated : Bool) { var rotateAction : SKAction! if animated { rotateAction = SKAction.rotateByAngle(angle, duration: 0.6) } else { rotateAction = SKAction.rotateByAngle(angle, duration: 0) } for node in self.children as! [SKSpriteNode] { node.runAction(rotateAction) } } } The problem I have is that that the

How to make SKScene have fixed width?

血红的双手。 提交于 2019-12-17 19:50:53
问题 I am making a spriteKit based game and wonder if I can make the SKScene fixed width (to make it easier to layout the sprites), and let it resize to the actual screen width while keeping the aspect ratio. Is it possible to achieve this goal and is it recommended (will sprites not be rendered clearly due to resizing)? 回答1: Giving the scene a fixed size is actually what we want to do in SpriteKit games. SpriteKit will than scale the game for each device using the scaleMode settings (defaults to