sprite-kit

Can't change SKPhysicsJointLimit maxLength after adding the joint to SKPhysicsWorld in Sprite Kit

谁说我不能喝 提交于 2019-12-23 15:42:53
问题 So, I've created a ring of SKSpriteNodes which are essentially rectangles that are joined together using pin joints. I'd like to suspend this ring inside of an SKShapeNode circle. I have connected each of the nodes to the SKShapeNode using SKPhysicsJointLimit's. This all works fine, and I get the effect that I'm looking for if I set the maxLength to the "right" number, which I determine subjectively. I've stored all of the limit joints inside of an Array, so I can get easy access, and I've

swift - Jump only when landed

江枫思渺然 提交于 2019-12-23 15:37:53
问题 I'm looking to restrict my character (cat), to only jump when it's either on the ground (dummy SKNode), or when on the tree (treeP SKNode). Currently I don't have any restrictions to touchesBegan and as a result the cat is able to fly through the air if the user clicks in quick succession, whilst this could be useful in other games it's not welcome here. If anyone could help me I'd be really happy. What i would like to do but have no experience would be to enable a click (jump), if the cat

iOS 9 Spritekit Double Tap Not Working on iPhone 6S

99封情书 提交于 2019-12-23 12:37:52
问题 I have been building a SpriteKit game for a while now. Its a card game that allows double-tap on card sprites for specific behaviors. Now that we're in iOS 9, double taps do not work at all on iPhone 6s. Works fine on iOS8, all devices. In my SKScene , i'm using the touchesBegan method to detect taps: -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint touchLocation = [touch locationInNode:self]; if(touch.tapCount==2) { NSLog(@

Vertex Shader in SpriteKit

一个人想着一个人 提交于 2019-12-23 12:35:24
问题 Is it possible to run an openGL Shader Program with both vertex and fragment shaders in SpriteKit? It seems only fragment Shaders are available. SceneKit offers it via the SCNProgram class 回答1: Actually vertex shaders are useful for much more than just transformations and projection. One of the most useful features is making calculations at each vertex, and then have the hardware interpolate the results, passing them to the fragment shader via 'varying' variables. (This is significantly more

SpriteKit SKPhysicsBody collision in one direction like a door you can only go through but not back

我是研究僧i 提交于 2019-12-23 10:39:43
问题 In SpriteKit SKPhysicsBody is it possible to have an object you can pass through but not go back. The idea is their is no collision in one direction so you go through and not go back, like a trap door. 回答1: I'm not quite sure one way physics are possible, but you should be able to mess with a physics body's collision bit mask while the game is running to achieve a similar affect. So you have have your door in an open state, and when it detects the player is touching it*, it changes the bit

How do you add a CIPixellate Core Image Filter to a Sprite Kit scene?

北城以北 提交于 2019-12-23 10:27:48
问题 How do you add a CIPixellate Core Image Filter to a Sprite Kit scene? I have a SpriteKit scene that is an SKScene or subclass of it. I want to add a Core Image filter to the scene. Specifically a CIPixellate filter, so I can have 8-bit game heaven for free. How do I do that? 回答1: It turns out this is not hard at all. It's just that the Core Image Filter docs are OLD and crufty and in the case of SpriteKit , the docs are flat out misleading or incomplete, including the SKEffectNode docs. The

Issues scaling sprite width to screen width

天大地大妈咪最大 提交于 2019-12-23 10:06:45
问题 Practically I am trying to achieve not too different from what was done in this question (scale a sprite regardless of it's position on the screen till it fills the screen width). Please see my code below: if touch?.tapCount == 2 { self.view?.isUserInteractionEnabled = false mySprite?.sprite.anchorPoint = CGPoint(x: (mySprite?.sprite.position.x)! / self.size.width, y: (mySprite?.sprite.anchorPoint.y)!) let scaleSpriteAction = SKAction.scaleX(to: self.size.width / (mySprite?.sprite.size.width)

Not able to apply impulse to SKSpriteNode physics body

大城市里の小女人 提交于 2019-12-23 09:38:07
问题 I am new to xcode's sprite kit and I'm an trying to apply an impulse to a SKSpriteNode's physics body. Here is how I create the scene: self.backgroundColor = [SKColor colorWithRed:0 green:0 blue:0 alpha:1.0]; self.physicsBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame]; self.physicsBody.friction = 0.0f; self.physicsWorld.gravity = CGVectorMake(0.0f, 0.0f); ballCategory = 1; wallCategory = 2; self.physicsBody.categoryBitMask = wallCategory; Here is how I create the player AND give it

Why is the coordinate system in sprite kit flipped and can I change that globally?

雨燕双飞 提交于 2019-12-23 08:57:57
问题 I noticed that in Sprite Kit the coordinate system is flipped. For example, here is a SKSpriteNode: SKSpriteNode *car = [SKSpriteNode spriteNodeWithImageNamed:@"car"]; car.position = CGPointMake(0, 0); [road addChild:car]; The car is positioned in the center of it's parent. When I set position to: car.position = CGPointMake(-50, 0); then it is positioned more to the left. But when I want to move it down, and increase Y, it moves UP! car.position = CGPointMake(-50, 20); In UIKit increasing Y

iOS spriteKit child nodes position with respect to view coordinates

拥有回忆 提交于 2019-12-23 08:05:43
问题 I have a child node added to another node. I want to get the child nodes position with respect to the views coordinates and not the parent nodes coordinates 回答1: Get the child node's position with respect to its parent, then use the convertPoint:fromNode: or convertPoint:toNode: method to convert from the parent node's coordinate system to the scene's coordinate system. (Remember, SKScene inherits from SKNode and is the root of the node hierarchy, so you can use it with either of those