Questions tagged [sktexture]

An SKTexture object is an image that can be applied to SKSpriteNode objects or particles created by a SKEmitterNode object.

SKTexture is part of , a graphics rendering and animation infrastructure to animate arbitrary textured images, or sprites.

is available on iOS () and OS X ()

145 questions
2
votes
1 answer

Limiting Array extension to a particular Array type?

Is it possible when writing an extension to Array to limit the extension just to a particular Array type? What I am trying to do is add an extension to Array that only works on Arrays of type [SKTexture]. I don't want the extension to do anything…
fuzzygoat
  • 26,573
  • 48
  • 165
  • 294
2
votes
0 answers

How to get the original image scale from an SKTexture?

I'm using sprite-kit in Swift and setting up textures using the SKTexture(rect:inTexture:) function. I am not using built-in texture atlases, instead I am creating the parent texture (the texture atlas) using SKTexture(imageNamed:). This is because…
jhabbott
  • 18,461
  • 9
  • 58
  • 95
2
votes
1 answer

EXC_BAD_ACCESS Error for SKTexture from textureFromNode With Swift 1.2

I've just encountered an error I haven't been able to solve. I get a EXC_BAD_ACCESS (code=1, address=0x30) failure when my SpriteKit scene is loading up. In viewWillAppear(...) my Game View Controller calls the loadGame(...) function: private func…
Mason
  • 271
  • 2
  • 12
2
votes
1 answer

SKPhysicsBody uses only part of SKTexture

I'm using an SKTexture with an image and set the SKPhysicsBody. Like that: var moleTexture = SKTexture(imageNamed: "moleTop1") leftPlayer = SKSpriteNode(texture: moleTexture) leftPlayer.physicsBody = SKPhysicsBody(texture: moleTexture, size:…
Christian
  • 22,585
  • 9
  • 80
  • 106
2
votes
2 answers

How to combine two SKTextures into one

I am trying to create a background fora game and have two background images. I can use two different SKSpriteNode(), SKTexture, SKAction.sequence..etc and some math to stitch them together but it comes out kind of choppy and also I cant seem to get…
Jeremy Sh
  • 609
  • 7
  • 24
2
votes
1 answer

Why am I unable to use the SKPhysicsBody constructor?

I am using spritekit with swift (ios8, xcode 6). When I use the physicsbody constructor self.physicsBody = SKPhysicsBody(texture: myTexture, size: myTexture.size()) , it fails every time, with the following error: :…
acahreonn
  • 54
  • 4
2
votes
1 answer

SpriteKit sometimes fails to load SKTexture

I am currently having a weird intermittent issue with SpriteKit and SKTexture preloading. I have multiple arrays of images which I preload in the following format: - (NSDictionary *)loadTexturesWithNames:(NSArray *)aNames { NSMutableDictionary…
Elliott D'Alvarez
  • 1,217
  • 16
  • 30
2
votes
1 answer

SKTexture preloading

When you preload textures using the spritekit preloadTextures function, it loads all the textures in the provided array into the memory at once. If you don't have the ability to split up your levels in your game with 'loading screens' but do have…
Max Hudson
  • 9,961
  • 14
  • 57
  • 107
1
vote
1 answer

Why SKTexture.preload raises memory issue on a real device?

I'm using SpriteKit for a 2D game and have an array of images for a simple animation. First, I'm creating an array with SKTextures to keep references to those images. var hyperLeapArray: [SKTexture] = [] for i in 0 ..< 90 { …
1
vote
0 answers

SKShapeNode fillTexture with rotation

I am having trouble figuring out how the fillTexture property of an SKShapeNode works when rotating that node. In this example I create a fan of 4 rotating blades around the center. The texture applied however varies in intensity as the blades…
andrewz
  • 4,729
  • 5
  • 49
  • 67
1
vote
2 answers

Is it possible to animate SKTexture with images?

I created a SKEmitterNode and I want the particleTexture property to animate images. This is what I'm trying, but it is only showing the first image: let animationImages = [UIImage(named: "image1")!, UIImage(named: "image2")!] let imageView =…
Joe
  • 355
  • 1
  • 10
1
vote
0 answers

SKTextureAtlas: retrieved texture behaving differently compared to original

I'm having so many problems with SKTextureAtlas I wonder whether it's worth persevering with. It seems to be broken on the simulator, but I'm also running into issues with it on device. My aim is to be able to generate - and save to device for…
Matthew R
  • 33
  • 8
1
vote
1 answer

How to use a SKScene as texture for SCNSphere?

I want to create a sphere of green color with a red point on its surface. One of the most efficient way that I found was to use a SKScene as the texture of the sphere with the desired properties, and display it as a whole inside a frame in SwiftUI.…
AtharvSalokhe
  • 463
  • 1
  • 4
  • 13
1
vote
0 answers

Corrupt image is displayed by image view when using an atlas texture & calling its cgImage() function

As soon as I updated my iPhone XS Max to 13.2.2 & macOS Catalina to 10.15.1 I returned working on my project & ran it onto my device. Immediately I noticed every UIImageView that was displaying a UIImage created from an SKTexture.cgImage() was…
Krekin
  • 1,516
  • 1
  • 13
  • 24
1
vote
0 answers

SpriteKit SKTextures memory footprint

I have simple background vector image with filesize around 100Kb. When loaded SKTexture, its size is 20Mb. Known formula for footprint in bytes is width * height * ( 32 / 8 ). Ok, matches. But 1 background Parallax layer: 3 * 20 = 60 3 layers …
elektricni
  • 319
  • 1
  • 5
  • 12