Skip to content

Commit

Permalink
add test case for camera and audio (cocos#1)
Browse files Browse the repository at this point in the history
* add test case for camera and audio

* add volume control
  • Loading branch information
gameall3d authored and jerrywwl committed Jul 23, 2019
1 parent c7e2da1 commit 0c0bf39
Show file tree
Hide file tree
Showing 30 changed files with 7,476 additions and 0 deletions.
10 changes: 10 additions & 0 deletions assets/cases/audio.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ver": "0.0.1",
"importer": "*",
"imported": true,
"uuid": "ccaf9333-a042-4512-a8bb-d376e32fa20c",
"displayName": "",
"files": [],
"subMetas": {},
"userData": {}
}
Binary file added assets/cases/audio/1.C(do).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/1.C(do).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "238dc619-3917-449b-a211-7d495cdd1415",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
Binary file added assets/cases/audio/2.D(re).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/2.D(re).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "5a68b56a-cf33-49b7-b2d8-2c529bec8c82",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
Binary file added assets/cases/audio/3.E(mi).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/3.E(mi).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "94dfced4-29c8-4ad1-9dfc-f45f7c90592e",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
Binary file added assets/cases/audio/4.F(fa).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/4.F(fa).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "345f2f13-c51d-4d2d-920f-bad8addccd37",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
Binary file added assets/cases/audio/5.G(sol).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/5.G(sol).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "b118553c-4127-4978-ae74-6147d946a843",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
Binary file added assets/cases/audio/6.A(la).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/6.A(la).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "6c2e4695-85ce-4cc0-9a6a-4e479d1b912b",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
Binary file added assets/cases/audio/7.B(si).mp3
Binary file not shown.
15 changes: 15 additions & 0 deletions assets/cases/audio/7.B(si).mp3.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.0",
"importer": "audio-clip",
"imported": true,
"uuid": "72296237-1986-402d-b420-ca68ca80dd0a",
"displayName": "",
"files": [
".mp3",
".json"
],
"subMetas": {},
"userData": {
"downloadMode": 0
}
}
39 changes: 39 additions & 0 deletions assets/cases/audio/AudioController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { _decorator, Component, AudioClip, AudioSourceComponent, LabelComponent, SliderComponent } from "cc";
const { ccclass, property } = _decorator;

@ccclass("AudioController")
export class AudioController extends Component {
/* class member could be defined like this */
// dummy = '';

/* use `property` decorator if your want the member to be serializable */
// @property
// serializableDummy = 0;

@property({type: [AudioClip]})
public clips: AudioClip[] = [];

@property({type: AudioSourceComponent})
public audioSource: AudioSourceComponent = null;

@property({type: LabelComponent})
public nameLabel: LabelComponent = null;

start () {
// Your initialization goes here.
}

// update (deltaTime: number) {
// // Your update function goes here.
// }

onButtonClicked(event, index: number) {
let clip: AudioClip = this.clips[index];
this.nameLabel.string = clip.name;
this.audioSource.playOneShot(clip);
}

onVolumeSliderChanged(eventTarget: SliderComponent) {
this.audioSource.volume = eventTarget.progress;
}
}
15 changes: 15 additions & 0 deletions assets/cases/audio/AudioController.ts.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ver": "1.0.812",
"importer": "typescript",
"imported": true,
"uuid": "f202177f-d457-4b8d-a26c-538479a1848c",
"displayName": "",
"files": [
".js"
],
"subMetas": {},
"userData": {
"moduleId": "project:///assets/cases/audio/AudioController.ts",
"importAsPlugin": false
}
}
192 changes: 192 additions & 0 deletions assets/cases/audio/BlackButton.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "BlackButton",
"_objFlags": 0,
"_parent": null,
"_children": [],
"_active": true,
"_level": 4,
"_components": [
{
"__id__": 2
},
{
"__id__": 3
},
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 130.789,
"y": 40,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 16,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransformComponent",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_contentSize": {
"__type__": "cc.Size",
"width": 25,
"height": 220
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.SpriteComponent",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_priority": 0,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_sharedMaterial": null,
"_spriteFrame": {
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@spriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.ButtonComponent",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"clickEvents": [],
"_interactable": true,
"_transition": 2,
"_normalColor": {
"__type__": "cc.Color",
"r": 214,
"g": 214,
"b": 214,
"a": 255
},
"_hoverColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_pressColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_normalSprite": {
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@spriteFrame"
},
"_hoverSprite": {
"__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@spriteFrame"
},
"_pressedSprite": {
"__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@spriteFrame"
},
"_disabledSprite": {
"__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@spriteFrame"
},
"_duration": 0.1,
"_zoomScale": 1.2,
"_target": {
"__id__": 1
},
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "71DvR0dCVNYbFY8oMKDAZt",
"sync": false,
"_synced": {
"default": false,
"serializable": false
}
}
]
12 changes: 12 additions & 0 deletions assets/cases/audio/BlackButton.prefab.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ver": "1.0.4",
"importer": "prefab",
"imported": true,
"uuid": "a4fc53d2-e7e2-48af-8470-1ca4d4329202",
"displayName": "",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}
Loading

0 comments on commit 0c0bf39

Please sign in to comment.