sprite-kit

Friction in SpriteKit

此生再无相见时 提交于 2019-12-06 12:23:38
问题 I'm working with Swift, SpriteKit and Xcode 6, I have a circle node on my screen and I can change the node's position with my finger, but I would like to implement a friction effect to this node, but I don't now how to do so, here's my code : class PlayScene: SKScene { let firstCircle = SKSpriteNode(imageNamed: "Circle") // theses 3 variables allows me to move the node according to my finger, but my finger don't have to touch the node var departCircleLocation = CGPoint() var

SpriteKit view throwing NSInvalidArgumentException

限于喜欢 提交于 2019-12-06 12:18:53
问题 I have this code below that loads a scene in the viewDidLoad: method. SKView *spriteView = (SKView *) self.view; spriteView.showsDrawCount = YES; spriteView.showsNodeCount = YES; spriteView.showsFPS = YES; PFPiePlanesScene *scene = [PFPiePlanesScene sceneWithSize:self.view.frame.size]; scene.scaleMode = SKSceneScaleModeAspectFill; [spriteView presentScene:scene]; When I call anything on the spriteView , it crashes with this message: Terminating app due to uncaught exception

How to dynamically create annotations for 3D object using scenekit - ARKit in iOS 11?

℡╲_俬逩灬. 提交于 2019-12-06 12:03:54
问题 I am working on creating annotations using overlaySKScene something similar to this(https://sketchfab.com/models/1144d7be20434e8387a2f0e311eca9b1#). I followed https://github.com/halmueller/ImmersiveInterfaces/tree/master/Tracking%20Overlay to create the overlay. But in the provided example, they are creating only one annotation and it is static. I want to create multiple annotations dynamically based on the number of child nodes we have and also should be able to position annotation on top

AVPlayer play SKVideoNode video ,I just can not control the playback

南笙酒味 提交于 2019-12-06 11:43:38
I am using the SpriteKit to play video,this is my code to create the SKVideoNode from AVPlayer: func CreateVideoViewWithAVPlayer(player:AVPlayer) { video = SKVideoNode(AVPlayer: player) let frameLayer=AVPlayerLayer(player: player) //video?. = CGRectMake(0, 0, 100, 100) video?.size = CGSize(width: 1024, height: 768) println(player.currentItem) video?.anchorPoint = CGPoint(x: 0, y: 0) video?.position = CGPoint(x: 0, y: 0) backgroundColor = SKColor.blackColor() self.addChild(video!) } And I create a AVPlayer give the function: let scene01 = GameScene(size: view.bounds.size) scene01

SKSpriteNode erratic swipe?

一笑奈何 提交于 2019-12-06 11:39:00
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]; UISwipeGestureRecognizer *recognizerDn = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:

Objective c - Animate background colour of SKScene

那年仲夏 提交于 2019-12-06 11:38:42
How would you go about animating the background colour of an SKScene? I've tried a UIView animate, but not surprisingly it didn't work. Is there an equivalent to do this in Sprite-Kit? I'm looking for something like this, but for Sprite-Kit: [UIView animateWithDuration:0.25 animations:^{ self.backgroundColor = [UIColor redColor]; }]; At the moment, as a work around I have overlayed a UIView over the SKView, but I would like something more flexible. I am relatively new to Sprite-Kit, so appologies if this is extremely simple to do! At the moment I have: -(id) initWithSize:(CGSize)size { if

Animate masked image in SpriteKit (SKCropNode)

我们两清 提交于 2019-12-06 11:26:11
问题 I'm using Sprite Kit to create my first iOS app, and I'm stumbling over what seems to be a pretty basic problem. I'm trying to animate the contents ( fillNode ) of a SKCropNode ( cropNode ). The code below sets up the SKScene just fine (I see the illustration masked correctly, placed over the background image in the right location)... SKSpriteNode *logoBG = [[SKSpriteNode alloc] initWithImageNamed:logoBackground]; logoBG.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self

Dpad for sprite kit

梦想的初衷 提交于 2019-12-06 11:02:00
问题 I an interested in trying to create a few games, namely in the new sprite kit. However, for the game that I have in mind I would rather use a directional pad vs a joy stick. Since I shall be moving over from Cocos, my old program no longer works (so neither will that dpad). Sadly, I have not come accross any tutorial that may help with implementing one in the new sprite kit (only joy sticks). I was wondering and hoping if anyone came across a simple dpad class from github or something or a

SpriteKit and UIKit compatibility: OpenGL error when migrating to Swift 2?

橙三吉。 提交于 2019-12-06 10:57:02
I just don't understand what is going on since I migrated to Swift 2. I have a Tabbed application and I am getting this error: <CAEAGLLayer: 0x7fb2e053fb40>: calling -display has no effect. Assertion failed: (length + offset <= _length), function commit_data, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/Jet_Sim/Jet-1.50/Jet/jet_types_OpenGL.h, line 863. I know it is really vague but I don't know where to start looking for bugs. Thanks. Edit: I just realized it might be related to the fact that I am trying to embed a GameViewController into the TabbedController. However, it did not

Nodes in a Scene from different layers will not interact

痞子三分冷 提交于 2019-12-06 10:53:26
问题 Apologies in advance as this Question involves allot of code. I have a GameScene with multiple layers holding Nodes/SpriteNodes for HUD/Scores/ etc. One layer, LayerProjectile, holds a Weapon Entity. Said Entity has both Sprite and Physics Components. Problem is the Projectile nodes in the LayerProjectile do not interact with nodes in the main layer (worldLayer), of the GameScene. All physics bodies are dynamic, and the GameScene has its PhysicWorldDelgate class GamePlayMode: SGScene,