添加一个获得金币的飞金币动画效果

This commit is contained in:
leo
2020-06-14 12:20:32 +08:00
parent 498c549bb0
commit 3069efccf6
29 changed files with 32483 additions and 0 deletions

51
ReceiveGoldAnimDemo/.gitignore vendored Normal file
View File

@@ -0,0 +1,51 @@
#/////////////////////////////////////////////////////////////////////////////
# Fireball Projects
#/////////////////////////////////////////////////////////////////////////////
/library/
/temp/
/local/
/build/
#/////////////////////////////////////////////////////////////////////////////
# npm files
#/////////////////////////////////////////////////////////////////////////////
npm-debug.log
node_modules/
#/////////////////////////////////////////////////////////////////////////////
# Logs and databases
#/////////////////////////////////////////////////////////////////////////////
*.log
*.sql
*.sqlite
#/////////////////////////////////////////////////////////////////////////////
# files for debugger
#/////////////////////////////////////////////////////////////////////////////
*.sln
*.pidb
*.suo
#/////////////////////////////////////////////////////////////////////////////
# OS generated files
#/////////////////////////////////////////////////////////////////////////////
.DS_Store
ehthumbs.db
Thumbs.db
#/////////////////////////////////////////////////////////////////////////////
# WebStorm files
#/////////////////////////////////////////////////////////////////////////////
.idea/
#//////////////////////////
# VS Code files
#//////////////////////////
.vscode/

View File

@@ -0,0 +1,2 @@
# hello-world
Hello world new project template.

View File

@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
"isGroup": false,
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
{
"ver": "1.2.7",
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}

View File

@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
"isGroup": false,
"subMetas": {}
}

View File

@@ -0,0 +1,51 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class GoldRecAnim extends cc.Component {
@property([cc.Node])
golodTemplate: cc.Node[] = [];
@property(cc.Node)
goldParent: cc.Node = null;
// onLoad () {}
start() {
}
playGoldAni(woldPos: cc.Vec2, complete: Function = null, goldCount: number = 5) {
function Range(num1: number, num2: number) {
if (num2 > num1) {
return Math.random() * (num2 - num1) + num1;
}
return Math.random() * (num1 - num2) + num2;
}
for (let i = 0; i < goldCount; i++) {
let node = cc.instantiate(this.golodTemplate[0]);
let pos = this.goldParent.convertToNodeSpaceAR(woldPos);
this.goldParent.addChild(node);
node.active = true;
node.setPosition(pos);
let range = 120;
let midPos = cc.v2(pos.x + Range(-range, range), pos.y + Range(-range, range));
let action = cc.sequence(cc.moveTo(0.3, midPos), cc.moveTo(0.3, 0, 0), cc.callFunc(() => {
node.destroy();
}));
node.runAction(action);
}
this.scheduleOnce(() => {
complete && complete();
this.goldParent.runAction(cc.sequence(cc.scaleTo(0.1, 1.1), cc.scaleTo(0.1, 1), cc.callFunc(() => {
this.goldParent.scale = 1;
})));
}, 0.7);
}
// update (dt) {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "9c26dacc-f0f1-43b8-9e96-828c367fe732",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,33 @@
import GoldRecAnim from "./GoldRecAnim";
const { ccclass, property } = cc._decorator;
@ccclass
export default class GoldViewMgr extends cc.Component {
@property(GoldRecAnim)
recAni: GoldRecAnim = null;
@property(cc.Label)
gold: cc.Label = null;
onLoad() {
}
start() {
}
onClick(event: cc.Event) {
let count = 5;
this.recAni.playGoldAni(cc.v2(300, 100), () => {
this.gold.string = (Number(this.gold.string) + count).toString();
})
}
// update (dt) {}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "4aa01a14-e7b1-4f03-adca-204c0be75376",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,22 @@
cc.Class({
extends: cc.Component,
properties: {
label: {
default: null,
type: cc.Label
},
// defaults, set visually when attaching this script to the Canvas
text: 'Hello, World!'
},
// use this for initialization
onLoad: function () {
this.label.string = this.text;
},
// called every frame
update: function (dt) {
},
});

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,6 @@
{
"ver": "1.0.1",
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
"isGroup": false,
"subMetas": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -0,0 +1,36 @@
{
"ver": "2.3.4",
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 195,
"height": 270,
"platformSettings": {},
"subMetas": {
"HelloWorld": {
"ver": "1.0.4",
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 195,
"height": 270,
"rawWidth": 195,
"rawHeight": 270,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,36 @@
{
"ver": "2.3.4",
"uuid": "41524580-b7b3-4714-b54f-467b3c19a53f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 72,
"height": 72,
"platformSettings": {},
"subMetas": {
"image_jinb": {
"ver": "1.0.4",
"uuid": "08ec161d-874e-4e42-a7ce-9a7b6029ea59",
"rawTextureUuid": "41524580-b7b3-4714-b54f-467b3c19a53f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 72,
"height": 72,
"rawWidth": 72,
"rawHeight": 72,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View File

@@ -0,0 +1,36 @@
{
"ver": "2.3.4",
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 2,
"height": 2,
"platformSettings": {},
"subMetas": {
"singleColor": {
"ver": "1.0.4",
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 2,
"height": 2,
"rawWidth": 2,
"rawHeight": 2,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}

30661
ReceiveGoldAnimDemo/creator.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"experimentalDecorators": true
},
"exclude": [
"node_modules",
".vscode",
"library",
"local",
"settings",
"temp"
]
}

View File

@@ -0,0 +1,9 @@
{
"engine": "cocos2d-html5",
"packages": "packages",
"version": "2.3.3",
"name": "ReceiveGoldAnimDemo",
"uuid": "79b4f11d-7930-454b-ba97-1d3b71509913",
"id": "a7bd712a-2352-47f6-a77d-63226364e9a4",
"isNew": false
}

View File

@@ -0,0 +1,13 @@
{
"excludeScenes": [],
"orientation": {
"landscapeLeft": true,
"landscapeRight": true,
"portrait": false,
"upsideDown": false
},
"packageName": "org.cocos2d.helloworld",
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"title": "hello_world",
"webOrientation": "auto"
}

View File

@@ -0,0 +1,7 @@
{
"excludeScenes": [],
"packageName": "org.cocos2d.helloworld",
"platform": "web-mobile",
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"title": "HelloWorld"
}

View File

@@ -0,0 +1,36 @@
{
"collision-matrix": [
[
true
]
],
"excluded-modules": [],
"group-list": [
"default"
],
"start-scene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
"design-resolution-width": 960,
"design-resolution-height": 640,
"fit-width": false,
"fit-height": true,
"use-project-simulator-setting": false,
"simulator-orientation": false,
"use-customize-simulator": false,
"simulator-resolution": {
"width": 960,
"height": 640
},
"last-module-event-record-time": 0,
"assets-sort-type": "name",
"facebook": {
"enable": false,
"appID": "",
"live": {
"enable": false
},
"audience": {
"enable": false
}
},
"migrate-history": []
}

View File

@@ -0,0 +1,6 @@
{
"game": {
"name": "未知游戏",
"appid": "UNKNOW"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,5 @@
{
"name": "TEMPLATES.helloworld.name",
"desc": "TEMPLATES.helloworld.desc",
"banner": "template-banner.png"
}

View File

@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [ "es2015", "es2017", "dom" ],
"target": "es5",
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "temp/vscode-dist",
"forceConsistentCasingInFileNames": true
},
"exclude": [
"node_modules",
"library",
"local",
"temp",
"build",
"settings"
]
}