Skip to content

Commit

Permalink
Add some test case scene of motion streak and particle system. (cocos…
Browse files Browse the repository at this point in the history
  • Loading branch information
caryliu1999 authored Nov 9, 2020
1 parent e273e75 commit bcc5b37
Show file tree
Hide file tree
Showing 35 changed files with 6,428 additions and 0 deletions.
12 changes: 12 additions & 0 deletions assets/cases/ui/24.motion-streak.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "fae49215-671d-4595-9669-93d73514da30",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}
56 changes: 56 additions & 0 deletions assets/cases/ui/24.motion-streak/motion-streak-ctrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Learn TypeScript:
// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { _decorator, Component, Node, MotionStreak, Texture2D, Animation } from 'cc';
const { ccclass, type } = _decorator;

@ccclass('MotionStreakCtrl')
export class MotionStreakCtrl extends Component {
@type(MotionStreak)
motionStreak: MotionStreak | null = null;

@type(Texture2D)
newTexture: Texture2D | null = null;

@type(Animation)
animationCom: Animation | null = null;

private _changed: boolean = true;
private _oldTexture: Texture2D | null = null;

onLoad () {
this._changed = true;
this._oldTexture = this.motionStreak!.texture;
}

onClick () {
if (this._changed) {
this.setMotionStreak(2, 3, 20, this.newTexture!);
}
else {
this.setMotionStreak(0.5, 1, 30, this._oldTexture!);
}
this._changed = !this._changed;
}

setMotionStreak (fadeTime: number, minSeg: number, stroke: number, texture: Texture2D) {
this.motionStreak!.fadeTime = fadeTime;
this.motionStreak!.minSeg = minSeg;
this.motionStreak!.stroke = stroke;
this.motionStreak!.texture = texture;
}

lateUpdate () {
if (!this.animationCom!.getState('move_around').isPlaying) {
this.animationCom!.play();
}
}

onDisable () {
this.animationCom!.stop();
}
}
16 changes: 16 additions & 0 deletions assets/cases/ui/24.motion-streak/motion-streak-ctrl.ts.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ver": "4.0.2",
"importer": "typescript",
"imported": true,
"uuid": "22ac104c-eecb-401b-8181-0e8d15c29eea",
"files": [
".js",
".trans"
],
"subMetas": {},
"userData": {
"importAsPlugin": false,
"moduleId": "project:///assets/cases/ui/24.motion-streak/motion-streak-ctrl.js",
"importerSettings": 3
}
}
Loading

0 comments on commit bcc5b37

Please sign in to comment.