skspritenode

SKTexture get image name

杀马特。学长 韩版系。学妹 提交于 2019-12-22 11:06:48
问题 Is there possible to get current image name from SKTexture from SKSpriteNode? I am a new in SpriteKit and I'm writing a little game. I need to detect when ninja will hit enemy. Something like this I am doing SKAction like - (void)setUpHit { SKTextureAtlas *hitAtlas = [SKTextureAtlas atlasNamed:@"Ninja_hit"]; SKTexture *hit1 = [hitAtlas textureNamed:@"Ninja_hit_1"]; SKTexture *hit2 = [hitAtlas textureNamed:@"Ninja_hit_2"]; SKTexture *hit3 = [hitAtlas textureNamed:@"Ninja_hit_3"]; SKTexture

Make edges of SKSpriteNode look smooth after rotation

百般思念 提交于 2019-12-22 10:40:04
问题 I create a SKSpriteNode like that: var shape:SKSpriteNode = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(CGFloat(sizeOfShape), CGFloat(sizeOfShape))) How can I achieve, that a SKSpriteNode has still smooth edges, after I've rotated it. Currently, it looks like that: As you see, the edges are jagged. 来源: https://stackoverflow.com/questions/25532760/make-edges-of-skspritenode-look-smooth-after-rotation

Sprite-Kit Change Image of Node when screen gets touched

浪子不回头ぞ 提交于 2019-12-22 10:38:22
问题 There is a hero that is controlled by tapping on the screen. I want the hero too look a little different every time the screen gets touched. What I did is setting up two images that are a little different. I want the image of the hero to be changed when there is a touch event. Until now I set up an array to save the information in but it kinda won't work out: NSMutableArray *heroFrames = [NSMutableArray array]; NSString* textureName = nil; if (UITouchPhaseBegan) { textureName = @"hero1.gif";

Giving properties of a UIButton to a SKSpriteNode in SpriteKit

守給你的承諾、 提交于 2019-12-22 01:05:49
问题 I was wondering if there was a way to give the properties of a UIButton like darkening the button once it has been pressed,... to a SKSpiteNode since an SKSpiteNode has more customization and because I am using SpriteKit . I have seen 1 other question like this but none of the answers worked. Here is the code I have to create the SKSpriteNode and to detect a touch on it: import SpriteKit class StartScene: SKScene { var startButton = SKSpriteNode() override func didMoveToView(view: SKView) {

how Xcode automatically remove skspritenode form its parent's node

China☆狼群 提交于 2019-12-21 22:04:19
问题 I'm new in objectif-c and sprite-kit development (but not in programming). So I'm starting the Apple's Spri. The app works perfectly, except that the nodes representing the rocks are automatically removed form its parent when rocks fall through the bottom of the scene. This, without implementing the -(void)didSimulatedPhysics method : - (void)didSimulatedPhysics { [self enumerateChildNodesWithName:@"rock" usingBlock:^(SKNode *node, BOOL *stop) { if (node.position.y < 0) [node removeFromParent

Is there a way to make a soft body with Spritekit using SKSpriteNode and PhysicsBody parameters?

做~自己de王妃 提交于 2019-12-21 20:06:07
问题 I have the following sprite that falls to the bottom of the screen: // The View self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame]; self.physicsWorld.contactDelegate = self; // The Sprite SKSpriteNode *cube = [[SKSpriteNode alloc] initWithImageNamed:@"cube"]; [cube setPosition:CGPointMake(160,250); [self addChild:cube]; // The Physics cube.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:cube.frame.size]; cube.physicsBody.dynamic = YES; cube.physicsBody

Accessibility (Voice Over) with Sprite Kit

随声附和 提交于 2019-12-21 16:55:16
问题 I'm attempting to add support for Voice Over accessibility in a puzzle game which has a fixed board. However, I'm having trouble getting UIAccessibilityElements to show up. Right now I'm overriding accessibilityElementAtIndex , accessibilityElementCount and indexOfAccessibilityElement in my SKScene. They are returning an array of accessible elements as such: func loadAccessibleElements() { self.isAccessibilityElement = false let pieces = getAllPieces() accessibleElements.removeAll

Blend UIColors in Swift

你说的曾经没有我的故事 提交于 2019-12-21 04:27:27
问题 I have two SKSpriteNode and their colors are defined like this: colorNode[0].color = UIColor(red: 255, green: 0, blue: 0, alpha: 1) colorNode[1].color = UIColor(red: 0, green: 255, blue: 0, alpha: 1) and I want to have a third SKSpriteNode colorized with a blend of the two first ones, the result should be like this : colorNode[2].color = UIColor(red: 255, green: 255, blue: 0, alpha: 1) but is there a way to addition two UIColors ? Like this : colorNode[2].color = colorNode[0].color +

SpriteKit - How to fix distortion in Node's animation?

不打扰是莪最后的温柔 提交于 2019-12-20 05:47:24
问题 I have created an animation of various PNGs, but there are various frames that stretch to the border so the node is 'filled'. The animation should look like the GIF that I have created using the same pictures. Does anybody know how to make the animation look like the GIF? GIF: Gif: Animation should look like this Actual: Extra slow Actual result of the code Border: Here you can see the border of the physics body that has the same size of the "node's border" I have tried to fix the problem by

Randomizing node movement duration

若如初见. 提交于 2019-12-20 05:30:34
问题 I am making a game in SpriteKit and I have a node that is moving back and forth across the screen and repeating using the code: let moveRight = SKAction.moveByX(frame.size.width/2.8, y: 0, duration: 1.5) let moveLeft = SKAction.moveByX(-frame.size.width/2.8, y: 0, duration: 1.5) let texRight = SKAction.setTexture(SKTexture(imageNamed: "Drake2")) let texLeft = SKAction.setTexture(SKTexture(imageNamed: "Drake1")) let moveBackAndForth = SKAction.repeatActionForever(SKAction.sequence([texRight,