質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Cocos2d

Cocos2dは、二次元のゲームや視覚的なアプリケーションを開発する為のオープンソースのフレームワークです。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

COCOS2D-X

COCOS2D-Xは、 2Dゲームを手軽に開発できるフレームワークのことです。 iPhone(iOS)向け、Android等に対応しており、 実質ワンソースで開発が可能です。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

0回答

722閲覧

cocos2d-xをWindowsからAndroidに移植した際にドット絵画像が半透明になる現象についての質問

yukkuri_19

総合スコア0

Cocos2d

Cocos2dは、二次元のゲームや視覚的なアプリケーションを開発する為のオープンソースのフレームワークです。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

COCOS2D-X

COCOS2D-Xは、 2Dゲームを手軽に開発できるフレームワークのことです。 iPhone(iOS)向け、Android等に対応しており、 実質ワンソースで開発が可能です。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2021/10/17 11:14

前提・実現したいこと

現在cocos2dにてWindowsで開発を行っていました。
今後スマートフォンに移植したいため、Androidの移植作業を行っていました。
メニュー画面は表示できるようにしたのですが、ドット絵のキャラクターが半透明の状態で表示されます。
すみませんがどなたかこの現象を解消する方法をご存じないでしょうか?

該当のソースコード

//画像ロード画面一部抜粋 void BasicPlayer::loadResources() { //ファイルパス std::string filePath[] = { "$Fighter_1.png", "$Fighter_2.png", "$Fighter_3.png", "$Fighter_4.png", "$Fighter_10.png", "$Fighter_11.png", "$Fighter_20.png", "$Fighter_40.png" }; //戻り画像フラグ bool returnImageFlag[][4]{ {true,false,false,false}, {true,false,true,true}, {true,true,false,false}, {true,false,false,true}, {false,false,true,true}, {false,false,false,false}, {true,true,false,true}, {true,false,false,false} }; //アニメーションスピード float animationSpeed[][4]{ {0.2,0.1,0.1,0.1}, {0.1,0.15,0.1,0.2}, {0.1,0.1,0.1,0.1}, {0.2,0.1,0.1,0.2}, {0.1,0.1,0.1,0.1}, {0.1,0.1,0.1,0.1}, {0.2,0.2,0.1,0.2}, {0.2,0.2,0.1,0.2} }; int count = 0; for (int i = 0; i < 8; i++) { // 文字列カウント // 対象の画像の読み取り(読み捨て用) // auto baseSprite = cocos2d::Sprite::create("RPG/Fighter/" + filePath[i]); auto baseSprite = cocos2d::Sprite::createWithSpriteFrameName(filePath[i]); // Spriteからテクスチャーの取得(読み捨て用) auto textureSource = baseSprite->getTexture(); textureSource->setAliasTexParameters(); textureSource->setAntiAliasTexParameters(); //baseSprite->retain(); //textureSource->retain(); // 今回はドット絵なのでアンチエイリアスをOFF //textureSource->setAliasTexParameters(); //textureSource->setAliasTexParameters(); // 1コマの大きさを取得しておく frameWidth = baseSprite->getContentSize().width / 4; frameHeight = baseSprite->getContentSize().height / 4; this->setContentSize(cocos2d::Size(frameWidth, frameHeight)); // 画像の半分の大きさを取っておく int harfWidth = baseSprite->getContentSize().width / 2; for (int y = 0; y < 4; y++) { // アニメーションを格納するオブジェクトの作成 cocos2d::Animation *animation = cocos2d::Animation::create(); animation->setDelayPerUnit(animationSpeed[i][y]); animation->setRestoreOriginalFrame(false); for (int x : { 0, 1, 2, 3 }) { // アニメーション4枚のテクスチャを考慮する int _x = frameWidth * x; int _y = y * frameHeight; CCLOG("(%d, %d)", _x, _y); // テクスチャーから画像を切り出し animation->addSpriteFrameWithTexture(textureSource, cocos2d::Rect(_x, _y, frameWidth, frameHeight)); } if (returnImageFlag[i][y]) { for (int x : { 2, 1, 0 }) { // 折り返しアニメーションを考慮する。 int _x = frameWidth * x; int _y = y * frameHeight; CCLOG("(%d, %d)", _x, _y); // テクスチャーから画像を切り出し animation->addSpriteFrameWithTexture(textureSource, cocos2d::Rect(_x, _y, frameWidth, frameHeight)); } } cocos2d::Animate *anime = cocos2d::Animate::create(animation); //anime->retain(); this->animatonTable.insert((PlayerDirection)(y + (4 * i) + count), anime); if(i==1 && y==1){ // アニメーションを格納するオブジェクトの作成 auto *animation = cocos2d::Animation::create(); animation->setDelayPerUnit(animationSpeed[i][y]); animation->setRestoreOriginalFrame(false); for (int x : { 3, 2, 1, 0 }) { // アニメーション4枚のテクスチャを考慮する int _x = frameWidth * x; int _y = y * frameHeight; CCLOG("(%d, %d)", _x, _y); // テクスチャーから画像を切り出し animation->addSpriteFrameWithTexture(textureSource, cocos2d::Rect(_x, _y, frameWidth, frameHeight)); } count++; cocos2d::Animate *anime = cocos2d::Animate::create(animation); //anime->retain(); this->animatonTable.insert((PlayerDirection)(y + (4 * i)+ count), anime); } } } // 攻撃判定 auto BoundBoxAttack = cocos2d::Sprite::create(); BoundBoxAttack->setTextureRect(cocos2d::Rect(0, 0, 30, 48)); // BoundBoxAttack->setTextureRect(cocos2d::Rect(20, 24, 30, 48)); BoundBoxAttack->setColor(cocos2d::Color3B(255, 0, 0)); BoundBoxAttack->setOpacity(0); BoundBoxAttack->setPosition(20, 24); // BoundBoxAttack->setPosition(0, 0); BoundBoxAttack->setTag(1); this->addChild(BoundBoxAttack); // プレイヤー当たり判定 auto BoundBoxSelf = cocos2d::Sprite::create(); BoundBoxSelf->setTextureRect(cocos2d::Rect(0, 0, 30, 48)); // BoundBoxSelf->setTextureRect(cocos2d::Rect(47, 24, 30, 48)); BoundBoxSelf->setColor(cocos2d::Color3B(0, 255, 255)); BoundBoxSelf->setOpacity(0); BoundBoxSelf->setPosition(47, 24); // BoundBoxSelf->setPosition(0, 0); BoundBoxSelf->setTag(2); auto box = BoundBoxSelf->getBoundingBox(); this->addChild(BoundBoxSelf); //this->setOpacity(0); //アップデート実行 //this->scheduleUpdate(); }

試したこと

setOpacity(255);
setColor(cocos2d::Color3B(255,255,255));
の状態にしても画像が半透明の状態で表示されます。

参考画像

イメージ説明

補足情報(FW/ツールのバージョンなど)

cocos2d-x 4.0
Android 9.0

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問