Questions tagged [swift]

Swift is a multi-paradigm, compiled programming language.

Filter by
Sorted by
Tagged with
0
votes
0answers
16 views

making an SKSpriteNode collide with another SKSpriteNode through the use of a projectile image

i am having a lot of troublefiguring out why my projectile will not shoot the image of luke. I have tried many different methods to try and counteract this but none of the strategies have seem to ...
0
votes
0answers
23 views

How to match user drawing with predefined drawing model?

i am trying to develop image recognition iOS app , i will have one reference image , and user has to draw something one screen and when user release finger , then i will convert his drawing into <...
0
votes
0answers
39 views

Move SKEmitterNode along with the trail that it creates

In Swift in SpriteKit, I have a SKEmitterNode that I have set up to make trails following the player. I have the target set to self, the scene so that it will make these trails when moved. I would ...
0
votes
1answer
129 views

Swift Error “unrecognized selector sent to instance 0x7f96875356e0”

This is the function i am trying to spawn obstacles in my game ...
0
votes
1answer
60 views

Swift get the true date

I have a game and want to reward the user for going on every day. I want to be able to get the true date somehow. I do not want the device date, because the user could just change it and get free ...
2
votes
1answer
30 views

tvOS game launch image shows on simulator but not on device

I’ve set up a launch image in XCode and it does show up in the simulator, but on the Apple TV it just displays a blurry gray background. The image is the correct size and doesn’t have any transparency....
0
votes
0answers
27 views

Managing character movement in 3D in AR

I'm working on an ARKit project where I need to manage the movement of an object (white box) on a plane (blue square). The characteristics of the environment are : The box can move only in 2D along ...
0
votes
1answer
54 views

Implementing score relative to total game time

How would one create score dependent on total time in game? I would like the score to count by 1000+ each second the game is running for. Later I am going to add some coins which will give my total ...
1
vote
1answer
144 views

Use GKEntity's component(ofType:) with inheritance

I'm writing a SpriteKit game in swift and making use of GameplayKit's entity-component system. There are many components that do different stuff but share the same methods in which they do it, so I ...
1
vote
1answer
41 views

UnrealEngine4 “backwards compatilibility”: Can I view a site that uses Unreal Engine4 on a very old laptop and still see in high definition?

Backwards compatible? The project: I want to render a high definition model on my personal website such that it'll be rendered in the highest definition possible on any device, from a 20-year-old ...
2
votes
1answer
97 views

Calculating the difference between two numbers using exponential growth

I think this is a very basic game programming question, but I am bad with math and new to programming & game programming so I'm looking for some advice. I'm making a 2D sprite game for iOS. Every ...
1
vote
1answer
309 views

calculating the trajectory of an object in SpriteKit when an impulse is applied to it

I want to make a trajectory line of little balls of where the object is going to go after an impulse, sort of like what is in Angry Birds. I did some research and it seems that the physics in ...
0
votes
1answer
77 views

Breaking up a map so countries can be colored separately in Spritekit

I'm currently trying to build a little strategy game where players take control of countries on an world. Each player's countries are represented by having a different color background but as each ...
2
votes
1answer
1k views

Get the up vector of the camera in ARKit

I'm trying to get the four vectors that make up the boundaries of the frustum in ARKit, and the solution I came up with is as follows: Find the field of view angles of the camera Then find the ...
1
vote
1answer
143 views

How can I make a sprite slow down to the speed of another sprite while following it?

I'm making a SpriteKit game where two SpriteNodes are in a maze. That maze is represented as a grid. One sprite (A) travels faster than the other (B). Items randomly pop up, and the sprites have to ...
0
votes
1answer
310 views

Don't know what to do with XML file and Spritesheet (Swift 3)

I'm new to spritesheets and game development in general. I have two files: 1) a .png spritesheet with tons of sprites and 2) a companion XML file with coordinates, anchor points, image names, and ...
1
vote
0answers
295 views

One SKSpriteNode with multiple PhysicsBodies?

I am making a game similar to Lunar Lander, when you land with your ship on different objects, etc... The issue I am having is that I have a Player SKSpriteNode (my Ship) with a slightly complex ...
2
votes
1answer
372 views

How do I apply touches to images, using Swift?

I need code this game for iOS, using Swift; but I don't know how to apply touches to images, using Swift. My attempts thus far have failed; touch!.view != image. <...
2
votes
1answer
85 views

How to move sprite as if not rotated when rotated 90 degrees?

We're making a Tetris like game and need help rotating shapes. Moving the shape works when there is no rotation. However, after rotation, snapping the shape to the grid fails because the vector ...
1
vote
0answers
290 views

Swift Spritekit: Create realistic driving sprite

How would I go by creating a realistic driving experience? I'm using iOS Swift 3 with SpriteKit using the functions applyForce to accelerate when I click the gas button and when braking I add ...
3
votes
1answer
341 views

How to determine the angular velocity needed move an object to a given position

I am trying to move two lines joint to a fixed position sprite in a way similar to that of a pendulum. I would like the lines to swing from end to end each time. The image below shows what I want to ...
2
votes
1answer
684 views

How can I create the water-like blur effect in Chameleon Run using SpriteKit and Unity?

As the character in Chameleon Run runs, a water-like blur effect is created. I would really appreciate some guidelines on how I could create this effect in SpriteKit and Unity. Please see the image ...
0
votes
1answer
1k views

The object can't rotate around z axis in SceneKit

I am doing an app with a functionality like a 3D compass, it can point to the direction where I want. The code is ...
2
votes
0answers
231 views

Swift gamedev options for linux [closed]

I recently tried out Swift. I found it to be awesome. But I'm unable to find any libraries for game development as I'm on Linux. Everything seems to be made for MacOS & iOS development. There ...
0
votes
0answers
119 views

Testing for connected maze cells

I'm currently in the middle of writing a game where there is a maze. The maze itself is already drawn ok, and once I have the layout I randomly rotate all the pieces. I have a 'start' cell that is a ...
1
vote
0answers
683 views

Fatal error: unexpectedly found nil while unwrapping an Optional value [closed]

I am trying to run this code but I keep on getting this error: fatal error: unexpectedly found nil while unwrapping an Optional value I don't understand why I'm getting it. Any hint? ...
1
vote
1answer
1k views

Tile based movement with SKAction (Xcode 8, Tile Map)

I am trying to make a game where the Hero can move like in Pokemon with SKActions. But the movement looks unprofessional and have delays. How can we handle to move the Hero smoothly with SKActions ...
1
vote
1answer
420 views

SpriteKit and Swift or Objective-C [closed]

As a newbie to iOS programming, I'm wondering which of these would be more conducive to the type of game I want to program. I've been tasked to program an iOS game for my company. They asked me to do ...
1
vote
2answers
2k views

How can I create a “wireframe” texture for a sphere in SceneKit?

I've been struggling to figure this out. I would like to have a sphere in SceneKit that looks like this: I think the easiest way would be to create a mostly transparent texture with the wireframe ...
5
votes
1answer
3k views

How do I pixelate a scene with SceneKit and Metal, in Swift?

I managed to get pixelation working by using the OpenGLES2 rendering API, and a CIFilter. But it was way too slow, so I want to use the Metal API and just have a very simple filter that pixelates ...
0
votes
1answer
83 views

Should the Sprites in my Boids implementation be backed by model objects?

This question is about the proper way to architect an implementation of Craig Reynolds Boids algorithm. I have an Agent object like this: ...
0
votes
1answer
831 views

CPU and RAM usage in OpenGL too high in Swift

My game is set up so the the display controls the game loop, usual in Cocoa. The callback function calls run() which is this. The thing is, the thread running the ...
0
votes
1answer
469 views

Collision Between SKSpriteNode and SKShapeNode

Im trying to create a collision between to objects. one is a SKSpriteNode and the other is a SKShapenode. the Code I have so far for Contact is : func didBeginContact( contact: SKPhysicsContact) { ...
1
vote
0answers
465 views

Failed to pass uniform in Metal shader modifier

I'm trying to write a simple shader able to pass the color to be used for drawing in the fragment shader, through a uniform. I load the shader modifier and pass the uniform: ...
4
votes
2answers
1k views

How to add a bump map in scene kit?

I'm trying to draw an Earth, as I've found the textures in this site: http://planetpixelemporium.com/earth.html I loaded the diffuse, specular and bump maps: ...
2
votes
1answer
2k views

Is it possible to use Metal and SceneKit at the same time?

All the tutorials that I've found online speak about using Metal alone, without any other supporting library. But I don't understand if it's possible to create a SceneKit game and then use a Metal ...
0
votes
1answer
106 views

How can I increase the hit range of a node?

How can I set the radius or the hit range of a node initialized with a texture? Of course I can do that with increasing the size of it, but actually I want to do this without resizing the picture ...
1
vote
0answers
210 views

How do I simulate vehicle movement in a non-gravity environment (e.g., space)?

As a series of small experiments, I've began to tinker with game development, specifically using SpriteKit and Swift. I'm looking to simulate a body moving through a non-gravity environment, ...
1
vote
1answer
6k views

Why is SCNNode.rotation property a four dimensional vector?

I don't understand why SCNNode's rotation property is a SCNVector4 instead of a SCNVector3. The documentation states that: The four-component rotation vector specifies the direction of the rotation ...
-1
votes
1answer
321 views

SceneKit – White layer covering my tube

I have a simple tube node in my scene that isn't displaying properly. When I rotate it to face the camera, more than half of it is covered by some invisible sheet. When I rotate the tube enough, it ...
2
votes
1answer
255 views

Pathfinding: longest route along tiles of same type

I'm programming a simple tile-based puzzle game, and I've gotten stuck trying to work out a pathfinding algorithm. Here's how the game is set out: The game board is (arbitrarily) 8 tiles wide by 8 ...
-1
votes
1answer
502 views

Fix buttons on screen

I've added buttons and SKCameraNode for my player. I got problem. When player moving left/right/jump all buttons dont follow for him. UPDATE class GameScene: SKScene, SKPhysicsContactDelegate { <...
1
vote
1answer
187 views

How to reregister gamecontroller changedvalue handler upon game scene reload

I'm working on a tvOS game that uses the siri gamepad controller. Everything works fine the first time out. If the user loses the round I reload the same scene using presentScene. After reloading the ...
-2
votes
1answer
366 views

Is it possible to use Box2D or Chipmunk in Swift & Cocos2d?

I am new to iOs programming. I wonder whether it is possible to use Box2D physic engine in Cocos2D with Swift. I am asking because I started to learn Swift. And I create Xcode project from ...
3
votes
1answer
500 views

Get Stencil buffer working iOS OpenGL ES 2.0

I have been trying to get this work but either get black screen or reporting error when using XCode to analyze the GL code like below. Any help appreciated. I am using Swift here if that making a ...
1
vote
0answers
127 views

swift fast enumeration on MDLAsset not working

I load an MDLAsset from my main bundle and get an compile error when fast iterating the asset object. Type 'MDLAsset' does not conform to protocol 'SequenceType' ...
0
votes
1answer
71 views

Does Apple allow customers to play over Bluetooth?

I'm a beginner in app development so sorry if my question is cheap :( I wanted to start developing a card game and i was wondering if apple allows customers to play over Bluetooth or not ( on ...
1
vote
1answer
1k views

spritekit sidescroller how to move hero through the level

I am trying to learn spritekit by working my way through developing a simple side scrolling game, but I cannot find a clear answer on how to move the hero through the level. The width of my ground ...
2
votes
1answer
1k views

Collisions between sprites in SpriteKit

I'm making a game in XCode using SpriteKit. The game has a player and different types of projectiles that he has to avoid. When the player collides with the projectiles, the score changes and the ...
1
vote
2answers
303 views

Where should I save game object's attributes (hp, score) in Swift?

Scenario: I have a game with several game objects on screen. Each can have different score and hitpoints. When I use collision detection for cannonball vs. ship (example) I need to know which ship is ...