sktexture

Textures used for animateWithTextures getting lost. Some frames show red X

房东的猫 提交于 2019-12-11 12:37:21
问题 My xCode project has the following.... AppDelegate GameViewController OpeningScene MainMenuScene GameScene When the game starts AppDelegate creates an array of all the textures I will use... [self.texturesArray addObject:[SKTexture textureWithImageNamed:@"Background05.jpg"]]; There's about 120 textures. Then I preload them using... [SKTexture preloadTextures:self.texturesArray withCompletionHandler:^{ NSLog(@"************ Finished Preloading Textures in AppDelegate.m *************"); [[STGD

How to get the original image scale from an SKTexture?

牧云@^-^@ 提交于 2019-12-11 04:05:15
问题 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 I already have atlases and sub-texture positions (in pixels) in my data files, not separate images. So the .size() of the SKTexture object is correct when the image is @2x (the size is half of the pixel dimensions). I calculate the sub-rect

Trying to use only a portion of a SKTexture using textureWithRect inTexture

自闭症网瘾萝莉.ら 提交于 2019-12-10 23:55:13
问题 What I'm doing is create a SKTexture based on the full image SKTexture *fullTexture = [SKTexture textureWithImageNamed:@"fullImage"]; I want to use the full width of the fullTexture, but only a portion of height of the texture, BUT, starting from the TOP of the full image. After figuring out that the width seems to be in percentage, I used the following code: SKTexture *croppedTexture = [SKTexture textureWithRect: CGRectMake(0,0,1,percentageY) can somebody give me the correct float values for

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

孤人 提交于 2019-12-10 06:10:38
问题 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

SKEffectNode to an SKTexture?

南笙酒味 提交于 2019-12-09 03:38:55
问题 SKEffectionNodes have a shouldRasterise "switch" that bakes them into a bitmap, and doesn't update them until such time as the underlying nodes that are impacted by the effect are changed. However I can't find a way to create an SKTexture from this rasterised "image". Is it possible to get a SKTexture from a SKEffectNode ? 回答1: I think you could try a code like this (it's just an example): if let effect = SKEffectNode.init(fileNamed: "myeffect") { effect.shouldRasterize = true self.addChild

How do I convert a PNG with alpha to RGBA4444 for using it in SpriteKit SKTexture?

家住魔仙堡 提交于 2019-12-08 00:04:24
问题 I have a stack of transparent PNGs that I'd like to use in a SKSpriteNode animation with SKTexture s. I'd need to adjust the memory usage of SKTexture s by reducing texture quality down from RGBA8888 to RGBA4444 . How would I initialize SKTexture with RGBA4444 texture format? Edit: IOS Swift Game Development Cookbook: Simple Solutions for Game Development suggests that SKTexture would support PVRTC files as follows: However, I couldn't get a SKSpriteNode to display a texture generated this

How do I convert a PNG with alpha to RGBA4444 for using it in SpriteKit SKTexture?

[亡魂溺海] 提交于 2019-12-06 06:06:56
I have a stack of transparent PNGs that I'd like to use in a SKSpriteNode animation with SKTexture s. I'd need to adjust the memory usage of SKTexture s by reducing texture quality down from RGBA8888 to RGBA4444 . How would I initialize SKTexture with RGBA4444 texture format? Edit: IOS Swift Game Development Cookbook: Simple Solutions for Game Development suggests that SKTexture would support PVRTC files as follows: However, I couldn't get a SKSpriteNode to display a texture generated this way. Luca Angeletti I just tried and in Xcode 8 the option Output Texture Atlas described here is no

SKTexture get image name

天涯浪子 提交于 2019-12-06 03:47:05
Is there possible to get current image name from SKTexture from SKSpriteNode? I am a new in SpriteKit and I'm writing a little game. I need to detect when ninja will hit enemy. Something like this I am doing SKAction like - (void)setUpHit { SKTextureAtlas *hitAtlas = [SKTextureAtlas atlasNamed:@"Ninja_hit"]; SKTexture *hit1 = [hitAtlas textureNamed:@"Ninja_hit_1"]; SKTexture *hit2 = [hitAtlas textureNamed:@"Ninja_hit_2"]; SKTexture *hit3 = [hitAtlas textureNamed:@"Ninja_hit_3"]; SKTexture *hit4 = [hitAtlas textureNamed:@"Ninja_hit_4"]; SKAction *hitAnimation = [SKAction animateWithTextures:@

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)

SKShapeNode filltexture() does not display image

心已入冬 提交于 2019-12-05 08:23:15
I want to create a circle that whose content is an image (.png), and based on the SKShapeNode class reference, I thought that I could use SKShapeNode.filltexture() function to set the texture to the image. But when i run the code below, I get the circle, but the image of the "cat-black" I am trying to load doesn't show. I checked that my Image.Assets have the image with the correct name, so something else is up. Any ideas? I attached the output below: func newCircle(photo:String, position:CGPoint) -> SKShapeNode { let circle = SKShapeNode.init(circleOfRadius: 27) circle.fillTexture = SKTexture