macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

-textureNamed:

INDEX>Sprite Kit> SKTextureAtlas

apple

テクスチャアトラスのデータストアからテクスチャを作成します
- (SKTexture *)textureNamed:(NSString *)name

解説

テクスチャアトラスのデータストアからテクスチャを作成します。

返り値

(SKTexture *)

新しいテクスチャ

引数

(NSString *)name

名前

クラス

SKTextureAtlas

使用可能

iOS 7.0以降

定義

SKTextureAtlas.h

参照

@property textureNamestextureNames

例文

NSMutableArray *plateFrames = [NSMutableArray array];
        SKTextureAtlas *plateAnimatedAtlas = [SKTextureAtlas atlasNamed:@"teppan"];
        
        NSUInteger numImages = plateAnimatedAtlas.textureNames.count;
        for (int i=0; i < numImages; i++) {
            NSString *textureName = [NSString stringWithFormat:@"%03d", i];
            SKTexture *temp = [plateAnimatedAtlas textureNamed:textureName];
            [plateFrames addObject:temp];
        }
        _plateFrames = plateFrames;
        
        SKTexture *temp = _plateFrames[0];
        _plate = [SKSpriteNode spriteNodeWithTexture:temp];
        _plate.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));
        [self addChild:_plate];

編集時のバージョン

OS X 10.9
iOS 7.0