forked from cocos/cocos-test-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some test case scene of motion streak and particle system. (cocos…
- Loading branch information
1 parent
e273e75
commit bcc5b37
Showing
35 changed files
with
6,428 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
assets/cases/ui/24.motion-streak/motion-streak-ctrl.ts.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Oops, something went wrong.