LoginSignup
9
9

More than 5 years have passed since last update.

cocos2dxで、フレーム付きのウィンドウを作る

Last updated at Posted at 2014-01-01

フレーム付きのウィンドウをつくる。
で、cocos2dxで伸縮自在なウィンドウを作るクラスを書きましたが、

どうやらcocosに元々あったようです(´・_・`)

該当クラス

CCScale9Spriteがそれです。

使い方

こんな感じに上下左右四隅と中央の画像を一枚にしたものを用意します。

frame.png

画像の全体サイズと中央の引き延ばす部分のサイズを指定して作成します。
その後、スプライトのサイズを指定すると、自動的に引き延ばして表示してくれます。

ccslace9sprite
    CCScale9Sprite* sprite = CCScale9Sprite::create("frame.png", 
            CCRectMake(0, 0, 30, 30),
            CCRectMake(10, 10, 10, 10));

    sprite->setContentSize(CCSizeMake(100, 100));
    sprite->setPosition(ccp(160, 160));
    addChild(sprite);
9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9