2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tmxで作った木の裏とかにキャラが回り込めるようにする

Posted at

領域のキャプチャ 123.png
こういうやつ。

まずはTiled Mapなどのtmx編集ツールを使って、backgroundレイヤーとforegroundレイヤーを作る。
foregroundレイヤーには裏に回りこませたいものを置く。この場合だと木の上部(黒い部分は透過色)。
領域のキャプチャ 125.png

backgroundレイヤーは木の幹を。
領域のキャプチャ 124.png

あとはjs側で各レイヤーのzOrderがforeground > キャラクター > backgroundになるように設定してやればOK.

var character = cc.Sptire.create('path/to/chara.png');
var tileMap = cc.TMXTiledMap.create('path/to/map.tmx');
tileMap.getLayer('foreground').setZOrder(100);
tileMap.getLayer('background').setZOrder(50);
tileMap.addChild(character, 70);

キャラクターがtileMap上にaddChildされていないとうまく重なり順が表現されないので注意。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?