sprite-kit

What is causing my SKAction timer to behave strangely?

孤人 提交于 2019-12-22 18:35:03
问题 Okay, I have a scene in which I have this method, createSceneContents , that gets called when didMoveToView gets called. In this method I have a couple of things that create the scenes, including a timer that spawns nodes like this: self.spawningSpeed = 1.5; self.enemyData = [[Enemy alloc]init]; SKAction *wait = [SKAction waitForDuration:1.5]; SKAction *run = [SKAction performSelector:@selector(spawningEnemy) onTarget:self]; self.spawnAction = [SKAction repeatActionForever:[SKAction sequence:

How to have textureFromNode produce texture for retina display?

放肆的年华 提交于 2019-12-22 18:33:27
问题 Platform: XCode 6.0 + iOS 7.0.4 Running the following code on iPad mini retina and expect the image of tmpLbl and node to render identically because the latter is initialized with the texture of the former, via textureFromNode . In reality tmpLbl , which is an SKLabelNode , renders at retina resolution but node , which is supposed to be a copy, is blurry, appearing to be a double-scaled rendition of a half-sized texture. I saw a post suggesting to put the source ( tmpLbl in the sample below)

Swift SpriteKit - Gradually increase rotation

旧时模样 提交于 2019-12-22 18:17:26
问题 I'm experimenting round with @nickfalk's answer on How to rotate sprite in sprite kit with swift on how to rotate a sprite in sprite kit. How would I adjust this to gradually increase rotation speed up to a maximum, then when the screen is clicked, it gradually slows down and goes in the reverse direction for x amount of time? Thanks! Toby. 回答1: Ok, the following (slightly messy proof of concept) spins a sprite at a constant speed. Upon tap+hold it gradually slows the rotation to a halt.

SKPhysicsContact Not Detecting categoryBitMask Collision

别等时光非礼了梦想. 提交于 2019-12-22 18:05:23
问题 So I have my "Floor.swift" class below which is basically a bunch of walls. I have objects coming from the top of the screen and once the Floor and SKSpriteNodes collide, I'd like the SKSpriteNode to be removed. Below is my Floor class. import Foundation import SpriteKit class Floor: SKNode { override init() { super.init() let leftWall = SKSpriteNode(color: UIColor.brown, size: CGSize(width: 5, height: 50)) leftWall.position = CGPoint(x: 0, y: 50) leftWall.physicsBody = SKPhysicsBody

How to change duration of executed SpriteKit action

与世无争的帅哥 提交于 2019-12-22 16:58:41
问题 I am executing the following SpriteKit action: SKAction *moveLeft = [SKAction moveByX:-moveX y:0 duration:moveDuration]; SKAction *moveRight = [moveLeft reversedAction]; SKAction *sequence = [SKAction sequence:@[moveLeft, moveRight]]; [my_node runAction [SKAction repeatActionForever:sequence]]; I want to slow down the action for few seconds (this happens as a result of a user tap), and after that return to the normal speed. I have tried to do so by using [my_node runAction [SKAction speedTo:

How to change duration of executed SpriteKit action

廉价感情. 提交于 2019-12-22 16:58:07
问题 I am executing the following SpriteKit action: SKAction *moveLeft = [SKAction moveByX:-moveX y:0 duration:moveDuration]; SKAction *moveRight = [moveLeft reversedAction]; SKAction *sequence = [SKAction sequence:@[moveLeft, moveRight]]; [my_node runAction [SKAction repeatActionForever:sequence]]; I want to slow down the action for few seconds (this happens as a result of a user tap), and after that return to the normal speed. I have tried to do so by using [my_node runAction [SKAction speedTo:

Create SKSpriteNode with an Asset Programmatically

ぃ、小莉子 提交于 2019-12-22 13:53:50
问题 I'm attempting to programmatically create an SKSpriteNode and give it a texture that is in my Assets.xcassets folder. I figured this would be a basic procedure, but I seem to be having a lot of troubles. For a reference, here is my asset catalog with the ground asset I'm trying to set to a SKSpriteNode : Here's the code to make the sprite node: sprite.texture = SKTexture(image: UIImage(named: spriteName)!) sprite.anchorPoint = CGPoint(x: 0, y: 1) sprite.position = CGPoint(x: 0, y: 0)

sprite kit collisions: ignore transparency?

喜你入骨 提交于 2019-12-22 12:53:33
问题 I am building a game with Xcode's spritekit. Its a platform game and right now it functions well with flat ground pieces. I was wondering if it was possible to ignore transparency in the png for collisions. That is to say, If i have a ground piece with a curved floor and transparency filling the troughs, can i make the player walk the curves instead of a square bounding box covering the whole thing? The only example i can find is in the Gamemaker GML language, you can do "precise" collisions

SKSpriteNode erratic swipe?

落爺英雄遲暮 提交于 2019-12-22 12:39:43
问题 I have created the following sprite kit node : SKSpriteNode *megadeth; megadeth = [SKSpriteNode spriteNodeWithImageNamed:@"megadeth_rocks.png"]; megadeth.name = @"awesome"; and added the swipe gesture as follows: -(void)didMoveToView:(SKView *)view{ UISwipeGestureRecognizer *recognizerUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUp:)]; recognizerUp.direction = UISwipeGestureRecognizerDirectionUp; [[self view] addGestureRecognizer:recognizerUp];

SKSpriteNode drag movement by touch

若如初见. 提交于 2019-12-22 12:39:30
问题 I'm trying to drag a SKSpirteNode around the screen by touching the screen. But I want to be able to do a constant movement of the Sprite, currently my code only moves the sprite to the location of my touch but if I hold and move the sprite will not follow. Moreover I don't want to "have" to touch the SKSpriteNode to activate the movement, I want to touch anywhere on the screen and to have a movement response from that SKSpriteNode. Here is my current code: class GameScene: SKScene { override