CocosCreator of KUOKUO take you one second grayed out (official comes Shader)

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/kuokuo666/article/details/100084405
engine

CocosCreator v2.1.2

Explanation

In the new version CocosCreator of material for us to join the system, and have built-in resources for our use in the new project.
Here Insert Picture Description

Let's look at what the material is grayed out!

Here Insert Picture Description

step

First, dragged into a picture.
Then get two buttons.

Here Insert Picture Description

Then let us create a new script!
(TS and JS care of small partners, I have given! Just the same, ha ha.)

First 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);
    }

}

Then we put the first ordinary material dragged, dragged into a second set of gray material.

Here Insert Picture Description

test

Here Insert Picture Description

Learned of it, O (∩_∩) O ~~

How kind, simple!

Add my blog :( QQ group inside the project, the group has a file oh)

706176551

we study together!

Guess you like

Origin blog.csdn.net/kuokuo666/article/details/100084405