LoginSignup
5
5

More than 5 years have passed since last update.

矩形スプライトを作る

Last updated at Posted at 2014-09-02

矩形スプライトを作って配置する場合、その画像を予め作っておき、

auto sprite = Sprite::create("rect.png");

で生成してもよいのだが、以下のように create() でスプライトを
生成し、setTextureRect(const Rect&) で矩形を生成することも可能だぞ。

auto sprite = Sprite::create();
sprite->setTextureRect(Rect(0, 0, 100, 200));

矩形の色を指定する場合は setColor(const Color3B&) を、
透明度を指定する場合は setOpacity(GLubyte) をコールするといいぞ。

sprite->setColor(Color3B(0, 255, 128));
sprite->setOpacity(128);

5
5
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
5
5