KUOKUOのCocosCreatorがグレーアウトあなたに1秒を取る(正式にはシェーダが来ます)

免責事項:この記事はブロガーオリジナル記事です、続くBY-SAのCC 4.0を著作権契約、複製、元のソースのリンクと、この文を添付してください。
このリンク: https://blog.csdn.net/kuokuo666/article/details/100084405
エンジン

CocosCreatorのv2.1.2

説明

材料の新しいバージョンCocosCreatorで、私たちは、システムに参加するために、新しいプロジェクトでの私たちの使用のために、組み込みのリソースを持っています。
ここに画像を挿入説明

のは、材料がグレーアウトされているものを見てみましょう!

ここに画像を挿入説明

ステップ

まず、絵にドラッグ。
次に、2つのボタンを取得します。

ここに画像を挿入説明

そして、私たちは新しいスクリプトを作成してみましょう!
(小さなパートナーのTSとJSのケア、私はハハ、!ちょうど同じ与えています。)

まずJS

cc.Class({
    extends: cc.Component,

    properties: {
        sprite: cc.Sprite,
        m0: cc.Material,
        m1: cc.Material
    },

    click_0 () {
        this.sprite.setMaterial(0, this.m0);
    },

    click_1 () {
        this.sprite.setMaterial(0, this.m1);
    }

});

TS

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Sprite) sprite: cc.Sprite = null;
    @property(cc.Material) m0: cc.Material = null;
    @property(cc.Material) m1: cc.Material = null;

    click_0 () {
        this.sprite.setMaterial(0, this.m0);
    }

    click_1 () {
        this.sprite.setMaterial(0, this.m1);
    }

}

その後、我々はグレー材料の第二セットにドラッグドラッグ最初の普通の材料を、置きます。

ここに画像を挿入説明

テスト

ここに画像を挿入説明

それを知った、O(∩_∩)O ~~

どのようなもの、シンプル!

プロジェクト内の私のブログ:( QQグループを追加し、グループ)はオハイオ州のファイルを持っています

706176551

私たちは一緒に学びます!

おすすめ

転載: blog.csdn.net/kuokuo666/article/details/100084405