免責事項:この記事はブロガーオリジナル記事です、続くBY-SAのCC 4.0を著作権契約、複製、元のソースのリンクと、この文を添付してください。
エンジン
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
私たちは一緒に学びます!