sprite-kit

SpriteKit : Stop specific action by tag

…衆ロ難τιáo~ 提交于 2020-01-05 08:43:13
问题 Is there any way to stop specific action by tag in Sprite-Kit ? [self stopActionByTag:kTagActionHeroFlapAnim]; //cocos2d [self stopActionByTag:kTagActionHeroHitAnim]; Like above Cocos2d calls, is there any way in Sprite-Kit ? SKAction *rep = [SKAction repeatActionForever:animAction]; //how to tag ? 回答1: You can use Action key to stop specific Action. You need to specify key. [sprite runAction:rep withKey:@"Move_fade_seq"]; [sprite removeActionForKey:@"Scale_fade_seq"]; 回答2: Your ability to

Present a UIViewController from SKScene

∥☆過路亽.° 提交于 2020-01-05 08:37:35
问题 I'm trying to present a UIViewController from a SKScene and I can't figure out how to do it. Most of what a Google search provides is how to present a share screen from a SKScene, but that is not what I'm trying to do. Just a regular View Controller that will have a button and a label (maybe a image as well). Here's my code in my Intro.m. This is not the Gameplay scene, just a intro screen with a title, play button and a remove ads button: #import "MyScene.h" #import "Intro.h" #import

Swift Sprite Kit Camera Movement

那年仲夏 提交于 2020-01-05 08:21:48
问题 I made a Camera in Sprite Kit focusing on a SKSpriteNode . There is a great Document by Apple: Apple Document However, the camera as it now is follows the SKSpriteNode immediately, while I want to have a little leeway. For e.g. the SKSpriteNode moves up and down after a touch is made, the camera follows the SKSpriteNode slowly from its origin point, and the maximum distance Height for the SKSpriteNode is half of the screen, and when the SKSpriteNode stands still, the camera and the

Why isn't the Codable init being called instead of the other required init?

自闭症网瘾萝莉.ら 提交于 2020-01-05 06:46:30
问题 I am building a game using SpriteKit and Swift 4, with a number of custom classes in the SKNode family. I am trying to use the Codable protocol with them to (hypothetically) make saving the game easier. As a bit of context, here is a high level overview of the main classes in the game: Hero class, custom SKSpriteNode, implements Codable. The Hero class, as a property, has a dictionary in the form of: [String:MapNode] MapNode class, custom SKSpriteNode, implements Codable. The MapNode class,

Multiple functions in Touch Function methods Sprite Kit

三世轮回 提交于 2020-01-05 04:59:09
问题 Please do not vote this down. If it's not a good question I will remove it immediately but here is something I am very confused with. I have a game in landscape view. Now, left of the screen is for my player to move around and right side of the screen is for its enemy to move around. Okay now, If I tab anywhere on right side of the screen, my player should shoot but if I tab left side of the screen, my player should move. so below is my code and I'm getting errors like this Thread 1 Signal or

Adding, Removing, and Caching SKNodes

岁酱吖の 提交于 2020-01-05 04:42:12
问题 Background info: I'm creating a SpriteKit 2D platform-style game with multiple "floors". When the user enters a "portal" he is transported to another floor (either one up or one down). If the user dies at a different floor from where the most recent spawnpoint is, he is transported back to the floor with the spawnpoint. Problem: After upgrading to iOS8, this scenario causes the game to crash with an EXC_BAD_ACCESS exception/ error. Even after going through multiple tutorials on how to debug

Spritekit: Separating randomly placed non-dynamic “block” nodes by a set X and Y value?

橙三吉。 提交于 2020-01-05 04:09:11
问题 my script below does exactly what i need it to do, add blocks to a scene in any random order in the view. the only problem is, as i increase the amount of "block" nodes, they tend to overlap on one another and clump up, I'm wondering if there is a way i can add a "barrier" around each block node so that they cannot overlap but still give a random feel? My current code is below: -(void) addBlocks:(int) count { for (int i = 0; i< count; i++) { SKSpriteNode *blocks = [SKSpriteNode

How many View Controllers should I have in my game?

非 Y 不嫁゛ 提交于 2020-01-04 09:18:33
问题 I'm starting to build my first game using spritekit. Right now I have only one View Controller which presents the start screen scene: override func viewDidLoad() { super.viewDidLoad() let scene = StartScreenScene() // Configure the view. let skView = self.view as SKView skView.showsFPS = true /* Sprite Kit applies additional optimizations to improve rendering performance */ skView.ignoresSiblingOrder = true /* Set the scale mode to scale to fit the window */ scene.scaleMode = .AspectFill

Merge all SKSpriteNode children into a single SKSpriteNode

大城市里の小女人 提交于 2020-01-04 08:07:05
问题 How can I take an SKSpriteNode and all its child SKSpriteNodes and merge them down into a single flattened SKSpriteNode with no children? Thanks. 回答1: Create a texture of the node and create a new sprite from that texture: SKTexture* tex = [self.scene.view textureFromNode:parentSprite]; SKSpriteNode* newSprite = [SKSpriteNode spriteNodeWithTexture:tex]; PS: be sure not to run this in init otherwise self.view will be nil. 来源: https://stackoverflow.com/questions/26075496/merge-all-skspritenode

Merge all SKSpriteNode children into a single SKSpriteNode

我们两清 提交于 2020-01-04 08:06:59
问题 How can I take an SKSpriteNode and all its child SKSpriteNodes and merge them down into a single flattened SKSpriteNode with no children? Thanks. 回答1: Create a texture of the node and create a new sprite from that texture: SKTexture* tex = [self.scene.view textureFromNode:parentSprite]; SKSpriteNode* newSprite = [SKSpriteNode spriteNodeWithTexture:tex]; PS: be sure not to run this in init otherwise self.view will be nil. 来源: https://stackoverflow.com/questions/26075496/merge-all-skspritenode