sprite-kit

ScrollView in SpriteKit

和自甴很熟 提交于 2019-12-05 17:42:24
I have found a few other questions and answers similar to this, but none of them quite work perfect for me. My vision is to have a horizontal scrollable view at the bottom of the screen where I can scroll through what will look like cards in a hand. Ideally, I could eventually make the card in the middle scaled up a bit and give it a highlighted look to show the user which card is selected. Even better would be if I could figure out how to keep the scroll view resizing to fir the number of sprites (cards) in the view. Anyways, I am still very new to XCode and Swift, so it is hard for me to

UIVisualEffectView doesn't blur it's SKView superview

拥有回忆 提交于 2019-12-05 17:15:33
I'm writing a SpriteKit game and faced a problem with blurred view, which lies on the SKView. It is supposed to slide from the right when game is paused and it should blur the content of it's parent view (SKView) just like control center panel in iOS 7. Here is the desired appearance: What I actually get is: In fact the view on the left is not totally black, you can see how highlights from the superview are slightly struggling through almost opaque subview, but no blur is applied. Is it an iOS 8 bug/feature, or is it my mistake/misunderstanding Here is my UIVisualEffectView subclass's

Swift physicsbody edge recognition issue

泄露秘密 提交于 2019-12-05 17:13:11
The following code recognizes the bottom and top edge of the scene and the ball bounces off as expected. However, the left and right edges of the scene are breached all the time. The ball goes off screen and then eventually returns back if enough force is applied. It is as if the edges of the scene are beyond the edges of the iphone simulator window. Can someone help? Thanks. import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView){ self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame) backgroundColor = UIColor.cyanColor() var ball = SKSpriteNode

SKTexture nearest filtering mode doesn't work (Making Pixel Art)

懵懂的女人 提交于 2019-12-05 16:49:33
I used a relatively small image (44pixel tall) and scaled it up to have a pixel art look. I tried to change the filtering mode to nearest so the anti-aliasing would disappear but it didn't. It appears with blurry edges. I tried the same with a background getting the same result. let myNode = SKSpriteNode() class GameScene: SKScene { func makeNode() { myNode.position = CGPoint(x: self.frame.size.width/2, y: self.frame.size.height/2) myNode.size = CGSize(width: 200, height: 200) myNode.texture = SKTexture(imageNamed: "image") myNode.texture!.filteringMode = .Nearest return self.addChild(myNode)

How to render a SKNode to UIImage

懵懂的女人 提交于 2019-12-05 16:44:35
问题 Just playing around with SpriteKit and am trying to figure out how to capture a 'grab' of an SKNode into a UIImage. With UIView (or a UIView subclass), I have used the layer property of the view to render into a graphics context. Eg. #import <QuartzCore/QuartzCore.h> + (UIImage *)imageOfView:(UIView *)view { UIGraphicsBeginImageContextWithOptions(view.frame.size, YES, 0.0f); CGContextRef context = UIGraphicsGetCurrentContext(); [view.layer renderInContext:context]; UIImage *viewShot =

-mouseMoved OSX does not get called in a sprite kit SKScene

余生长醉 提交于 2019-12-05 16:21:50
The following responder (defined in NSResponder) does not get called in an SKScene in OSX: -(void) mouseMoved:(NSEvent *)theEvent { DLog(@"TEST"); } I have said the window to accept mouse moved events in the app delegate. _window.acceptsMouseMovedEvents = YES; Thank you in advance. SOLUTION: Add to the app delegate: _window.acceptsMouseMovedEvents = YES; [_window makeFirstResponder:self.skView.scene]; Add to the app delegate: _window.acceptsMouseMovedEvents = YES; [_window makeFirstResponder:self.skView.scene]; In swift window.acceptsMouseMovedEvents = true; window.makeFirstResponder(self

TouchEvents in watchOS 3 SpriteKit?

北战南征 提交于 2019-12-05 16:03:08
When using SpriteKit in watchOS 3, how do you handle the touch events? I am porting the SpriteKit games from iOS and the codes below won't work. Or you have to control the WKInterfaceController somehow? override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {} After a lot of frustration with the same issue, I wound up using gesture recognizers,

Is there a way to change the font and location of SpriteKit debug data?

血红的双手。 提交于 2019-12-05 15:57:48
Basically what it says in the title. Is there a way to change the font and or location of SpriteKit debug data? The data that we set in the viewController: skView.showsFPS = YES; skView.showsNodeCount = YES; skView.showsDrawCount = YES; You can add such debugging information to the scene by yourself: https://developer.apple.com/library/ios/documentation/GraphicsAnimation/Conceptual/SpriteKit_PG/Actions/Actions.html Example: Adding a Debugging Overlay section. No. Those are all part of the SKView class which offers no user changeable attributes in regards to the above 3 items. 来源: https:/

Centre a SKLabelNode on a SKSpriteNode

落爺英雄遲暮 提交于 2019-12-05 15:21:02
问题 I have an SKLabelNode that is the child of a SKSpriteNode because I'm trying to create a Button class to create buttons in an easier way. I've tried a couple of things using the anchor point of the SKSpriteNode, but I don't quite understand exactly what is going on. How do I centre the label onto the sprite (it's parent node)? 回答1: I realized how to solve this...here's what i did. Keep in mind that I have a class called Button that is a subclass of SKSpriteNode. In the Button.m class I have

SpriteKit Gesture Recognizer

喜欢而已 提交于 2019-12-05 15:17:11
Hi I'm trying to use gesture recognizer with my sprite kit game , i wrote this code @interface GameScene() <UIGestureRecognizerDelegate>{ UISwipeGestureRecognizer *swipeGestureLeft; ISwipeGestureRecognizer *swipeGestureRight; } @end @implementation GameScene -(id)initWithSize:(CGSize)size{ if(self = [ super initWithSize:size]){ } return self; } -(void)didMoveToView:(SKView *)view{ swipeGestureLeft = [[UIGestureRecognizer alloc]initWithTarget:self action:@selector(swipeLeft)]; [swipeGestureLeft setDirection:UISwipeGestureRecognizerDirectionLeft]; [view addGestureRecognizer:swipeGestureLeft];