macOS/iOS API解説

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

目次

+atlasNamed:

INDEX>Sprite Kit> SKTextureAtlas

apple

アプリケーションバンドルのデータストアからアトラスを作成する
+ (SKTextureAtlas *)atlasNamed:(NSString *)name

解説

アプリケーションバンドルのデータストアからアトラスを作成する。
テクスチャアトラスを見つけることが出来なければ例外を投げます。

返り値

(SKTextureAtlas *)

新しいテクスチャアトラス

引数

(NSString *)name

テクスチャアトラスの名前、.atlas拡張子はいらない。

クラス

SKTextureAtlas

使用可能

iOS 7.0以降

定義

SKTextureAtlas.h

参照

例文

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