sprite-kit

SpriteKit SKPhysicsBody with Inner Edges

和自甴很熟 提交于 2019-12-14 04:17:52
问题 I have created an SKSpriteNode called let's say Map that has an edge path that I have defined (some simple polygon shape). What I am trying to figure out is how to add several other edge paths that would act as interior edges of the Map . As if the "map" as a whole did in fact have holes . Some sort of inner boundary shapes that could act with Map as a whole: one edge path (as shown below) © I understand that there is a method that allows for creating an SKPhysicsBody with bodies (some

Combining scenekit and spritekit in a single screen

痞子三分冷 提交于 2019-12-14 04:17:36
问题 Apologies if this is a newbie question, i'm still trying to find my way around Swift and SpriteKit / SceneKit. Is it possible to combine SpriteKit and SceneKit in a single view, e.g. using SpriteKit to render a map in portion of the screen while using SceneKit to render the main 3D view? 回答1: Yes you can and it was shown in various demos at WWDC. Take a look at the overlaySKScene property of SCNSceneRenderer . 回答2: One way of using SpriteKit within SceneKit is as follows: SCNView *sceneView =

SpriteKit: Change texture based on direction

淺唱寂寞╮ 提交于 2019-12-14 04:04:22
问题 I'm using an on-screen DPAD to move my character but I'm having trouble with passing in my sprites based on direction. Basically what I need is if the character is moving up, use the walking up animation. Moving down, use down. Left, use left, and right, use right animations. The angles are what I'm really having trouble with. This is the code that I'm using to move my character. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint

Not appearing all level after SKTransition

纵然是瞬间 提交于 2019-12-14 03:33:32
问题 I am trying to do a transition between game menu and the first level. But instead of all Level1 (it is built by using an Level1.sks file(here I have designed a level) and Level1.swift(here I have created my "hero" etc.)) on the screen appears just hero, but no locations that was designed in Level1.sks. How I can resolve this problem? override func touchesEnded(touches: NSSet, withEvent event: UIEvent) { for touch: AnyObject in touches { let location = touch.locationInNode(self) if (playbutton

Issue with multiple different collions in SpriteKit (iOS app written in Objective-C with Xcode)

☆樱花仙子☆ 提交于 2019-12-14 02:36:21
问题 I am currently building an iOS app in Objective-C. The idea of the app is that you have some sort of rocket ship navigating through an asteroid belt of sorts. It is played in portrait mode. Now, there are two different kinds of asteroids. Normal ones that make you lose when you crash into them, and golden ones that you shoot at to get coins. For collisions, I am using the code from a Ray Wenderlich SpriteKit tutorial. The categories are set up like this: static const uint32_t playerCategory =

Retain cycle suspected in closure

余生长醉 提交于 2019-12-14 02:26:34
问题 I suspect that the following function, which I use in my GameScene class in order to manage the accelerometer's input, is keeping my scene from deinitializing when I transition to another scene: class GameScene: SKScene { let motionManager = CMMotionManager() var xAcceleration = CGFloat(0) // Some stuff // override func didMove(to: .... func setupCoreMotion() { motionManager.accelerometerUpdateInterval = 0.2 let queue = OperationQueue() motionManager.startAccelerometerUpdates(to: queue,

Deciphering instruments readout

浪子不回头ぞ 提交于 2019-12-14 02:15:07
问题 CPU usage at ~50% / energy usage "Very high" in my sprite kit game. I use tile sets to setup the levels. After the tile sets are in place I use clear, non-dynamic sprites with collision/contact bit masks for floors/walls/etc. I get a constant 60FPS, and my memory usage is only ~32MBs. For animations as of now I have: 3 roving (forever) enemies which are not removed from the scene unless stepped on and killed 9 vertically moving platforms (up and down forever). Each platform uses an SKaction

SpriteKit “START” button that calls start() in the scene its in

拟墨画扇 提交于 2019-12-14 02:13:41
问题 How do I compose a touchesBegun command in a StartButton class that calls start() in the scene any instance of itself has been placed in? I know... probably OOP 101. But well beyond me, today. UPDATE: Here is how I currently (partially) solve the problem. It doesn't feel right, but it works, somewhat. Not as much as I'd like: override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { SoundManager.playSceneStartSound() run(ready) if CEO.startButtonIsActive{ print("We're

Handling interruptions in Sprite Kit - can't get sound effects via [SKAction playSoundFileNamed: to work after interruption

删除回忆录丶 提交于 2019-12-14 02:02:33
问题 Handling interruptions in Sprite Kit - can't get sound effects via [SKAction playSoundFileNamed: to work after interruption (like a phone call) Was able to get background music to restart after interruption by adding AVAudioPlayerDelegate to my GameScene.h then adding to my GameScene.m -(void)audioPlayerBeginInterruption:(AVAudioPlayer *)player { [_backgroundAudioPlayer pause]; } -(void)audioPlayerEndInterruption:(AVAudioPlayer *)player { [_backgroundAudioPlayer prepareToPlay]; [

How to implement mouse joint in Sprite Kit?

岁酱吖の 提交于 2019-12-14 01:43:38
问题 I have working implementation of drag and drop feature written in Cocos2d + Box2d for iOS. I need to port it to Sprite Kit. The logic is pretty basic: when user touching the screen, find sprite under the finger create mouse joint between found sprite and the scene's physics body, set joint's target to position of touch when touches moved, update joint's target to new position when touches ended, remove the joint Everything is working quite well. I like the way physics is simulated when