sktexture

Export SKTexture to a UIImage with alpha channel

天大地大妈咪最大 提交于 2021-01-28 19:43:44
问题 I would like to be able to export my SKTexture to an external image file. I have been able to achieve this using the following code. However it suffers from the critical flaw that the alpha channel is ignored even thoough the view is not opaque and all background colours are set to clear. - (void)export:(CGRect)bounds texture:(SKTexture *)texture path:(NSString *)path{ UIGraphicsBeginImageContextWithOptions(bounds.size, NO, [UIScreen mainScreen].scale); SKView *view = [[SKView alloc]

UImage loads entire SKTextureAtlas instead of just SKTexture

こ雲淡風輕ζ 提交于 2020-04-18 12:50:08
问题 I need texture with 'trueName' to load into my myImageViewOutlet.image. The result I am getting is the entire atlas rendering into it. My code is as follows let myTextureAtlas = SKTextureAtlas.init(named: "myGameTextures") // let texture = myTextureAtlas.textureNamed(trueName) // will render the entire atlas, instead of just the texture by trueName let texture = myTextureAtlas.textureNamed(trueName+”bad name“) // will produce the placeholder image by sprite kit by itself just fine, but it's

UImage loads entire SKTextureAtlas instead of just SKTexture

丶灬走出姿态 提交于 2020-04-18 12:49:49
问题 I need texture with 'trueName' to load into my myImageViewOutlet.image. The result I am getting is the entire atlas rendering into it. My code is as follows let myTextureAtlas = SKTextureAtlas.init(named: "myGameTextures") // let texture = myTextureAtlas.textureNamed(trueName) // will render the entire atlas, instead of just the texture by trueName let texture = myTextureAtlas.textureNamed(trueName+”bad name“) // will produce the placeholder image by sprite kit by itself just fine, but it's

Swift : How to handle a lot of textures in memory

*爱你&永不变心* 提交于 2020-01-01 16:48:10
问题 I have a lot of characters in my game and because of that I have so many textures. When a texture atlas is loaded (containing about 5 different image textures) it increases the memory use and keeps it there at that amount. So the more textures just keeps driving that number up and up until sometimes the application crashes. I don't need all the characters at once, how can i maybe load some character textures when I need them and deallocate the others when i don't, but ill need to be able to

SKTexture preloading

白昼怎懂夜的黑 提交于 2019-12-30 07:31:38
问题 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 separate levels with different image files than each other, how can you keep from storing all the images in memory at once without sacrificing frame rate when spritekit loads the images when it needs to? 回答1: You could create a singleton class with

Create \(Use) SKView as \(in a) factory \(static class)

≯℡__Kan透↙ 提交于 2019-12-29 08:26:17
问题 I want to make an SKView I can use as a factory to make SKShapeNodes and "render" them to textures. But I can't find how I would initialise such a thing, and am having no luck, at all. How do I make a standalone SKView for this purpose? Or is there a better way to do this that avoids using the gamescene? Here's my FUTILE Effort at making a factory, this complains that texture(from: ) is ambiguous . I have no idea what that means. import SpriteKit class Make: SKView{ static func circle() ->

Create \(Use) SKView as \(in a) factory \(static class)

若如初见. 提交于 2019-12-29 08:26:09
问题 I want to make an SKView I can use as a factory to make SKShapeNodes and "render" them to textures. But I can't find how I would initialise such a thing, and am having no luck, at all. How do I make a standalone SKView for this purpose? Or is there a better way to do this that avoids using the gamescene? Here's my FUTILE Effort at making a factory, this complains that texture(from: ) is ambiguous . I have no idea what that means. import SpriteKit class Make: SKView{ static func circle() ->

Does a SKTexture from a SKTextureAtlas support the mipmap feature?

不想你离开。 提交于 2019-12-23 21:32:40
问题 From apples documentation: "You can only request mipmaps if both of the texture’s dimensions are a power of two." However, it's unclear whether the SKTextures from SKTextureAtlas's also support this feature (since they're essentially a bit different in nature). I ask the question because it's actually hard to see if anything is getting mipmapped from the results. 回答1: First off a SKTexture from a SKTextureAtlas does not support mipmapping. Secondly sometimes mipmapping doesn't even work with

SKTexture get image name

杀马特。学长 韩版系。学妹 提交于 2019-12-22 11:06:48
问题 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

SKShapeNode filltexture() does not display image

我们两清 提交于 2019-12-22 05:27:01
问题 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