Commit bfb54bdd authored by liujiangnan's avatar liujiangnan

feat: 初始化

parent fe63b0cb
This diff is collapsed.
...@@ -2,10 +2,10 @@ cc.Class({ ...@@ -2,10 +2,10 @@ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
// videoPlayer: { videoPlayer: {
// default: null, default: null,
// type: cc.VideoPlayer type: cc.VideoPlayer
// }, },
ProgressBar: { ProgressBar: {
default: null, default: null,
type: cc.ProgressBar type: cc.ProgressBar
...@@ -41,18 +41,52 @@ cc.Class({ ...@@ -41,18 +41,52 @@ cc.Class({
barTag: { barTag: {
default: null, default: null,
type: cc.Node type: cc.Node
},
bar: {
default: null,
type: cc.Node
} }
// defaults, set visually when attaching this script to the Canvas // defaults, set visually when attaching this script to the Canvas
// text: 'Hello, World!' // text: 'Hello, World!'
}, },
_designSize: null, // 设计分辨率
_frameSize: null, // 屏幕分辨率
_mapScaleMin: null, // 场景中常用缩放(取大值)
_mapScaleMax: null, // 场景中常用缩放(取小值)
_cocosScale: null, // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
cc.director['_scene'].width = frameSize.width;
cc.director['_scene'].height = frameSize.height;
},
// use this for initialization // use this for initialization
onLoad: function () { onLoad: function () {
const {width: dw, height: dh} = cc.view.getDesignResolutionSize();
const {width: fw, height: fh} = cc.view.getFrameSize();
const minScale = Math.min(fw/dw, fh/dh);
// cc.Canvas.instance.node.scale = minScale;
this.initSize();
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
this._isReadyToPlay = false; this._isReadyToPlay = false;
window['vv'] = this; window['vv'] = this;
...@@ -99,7 +133,7 @@ cc.Class({ ...@@ -99,7 +133,7 @@ cc.Class({
}); });
this.initdDrag(); this.initdDrag();
// console.log(11111) // console.log(11111)
this.videoPlayer = this.node.getComponent(cc.VideoPlayer); // this.videoPlayer = this.node.getComponent(cc.VideoPlayer);
this.videoPlayer.getImpl = function() { this.videoPlayer.getImpl = function() {
return this._impl; return this._impl;
} }
...@@ -167,7 +201,7 @@ cc.Class({ ...@@ -167,7 +201,7 @@ cc.Class({
const pgBar = this.ProgressBar.node; const pgBar = this.ProgressBar.node;
this.tw = new (function(){ this.tw = new (function(){
this._tw = cc.tween(pgBar).delay(3).to(.6, { this._tw = cc.tween(pgBar).delay(3).to(.6, {
opacity: 0 opacity: 255
}).call(() => { }).call(() => {
console.log('This is a callback'); console.log('This is a callback');
this.running = false; this.running = false;
...@@ -267,6 +301,7 @@ cc.Class({ ...@@ -267,6 +301,7 @@ cc.Class({
let newX = percent * maxX; let newX = percent * maxX;
newX = Math.min(maxX, Math.max(newX, minX)); newX = Math.min(maxX, Math.max(newX, minX));
this.barTag.x = newX; this.barTag.x = newX;
this.bar.width = newX;
}, },
formatTime(time) { formatTime(time) {
if (time === undefined) { if (time === undefined) {
...@@ -302,6 +337,7 @@ cc.Class({ ...@@ -302,6 +337,7 @@ cc.Class({
}, },
play(){ play(){
this.videoPlayer.node.active = true;
this.videoPlayer.play(); this.videoPlayer.play();
this.triggerInteractive() this.triggerInteractive()
}, },
...@@ -320,6 +356,7 @@ cc.Class({ ...@@ -320,6 +356,7 @@ cc.Class({
}, },
replay(){ replay(){
this.videoPlayer.currentTime = 0; this.videoPlayer.currentTime = 0;
this.videoPlayer.play();
this.triggerInteractive() this.triggerInteractive()
}, },
......
{
"ver": "1.1.0",
"uuid": "2b4706dd-52dd-463a-865d-a5cee0dd7598",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "7babf1e0-399f-4c50-a3cc-c747f4d314e4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 21,
"height": 21,
"platformSettings": {},
"subMetas": {
"barbg": {
"ver": "1.0.4",
"uuid": "9c0a9a1c-f515-419f-a98b-d1926c0d9791",
"rawTextureUuid": "7babf1e0-399f-4c50-a3cc-c747f4d314e4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 21,
"height": 21,
"rawWidth": 21,
"rawHeight": 21,
"borderTop": 10,
"borderBottom": 10,
"borderLeft": 10,
"borderRight": 10,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "fe2f92d5-98f1-488f-ac31-a8a2552d1023",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 192,
"height": 234,
"platformSettings": {},
"subMetas": {
"bartag": {
"ver": "1.0.4",
"uuid": "88113a42-ecd9-4466-92f3-473d8d95f1df",
"rawTextureUuid": "fe2f92d5-98f1-488f-ac31-a8a2552d1023",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 192,
"height": 234,
"rawWidth": 192,
"rawHeight": 234,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "3958e883-f0f5-4d3d-a194-d3a19297733d",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 135,
"height": 138,
"platformSettings": {},
"subMetas": {
"direction": {
"ver": "1.0.4",
"uuid": "ad3edd55-2906-4438-937b-9bd900ec782c",
"rawTextureUuid": "3958e883-f0f5-4d3d-a194-d3a19297733d",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 135,
"height": 138,
"rawWidth": 135,
"rawHeight": 138,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8a3fc755-6a40-4dcb-aae0-b31cb9c3a699",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 213,
"height": 180,
"platformSettings": {},
"subMetas": {
"pause": {
"ver": "1.0.4",
"uuid": "3c9a6fa7-92a9-439a-9771-9dfe16c27d02",
"rawTextureUuid": "8a3fc755-6a40-4dcb-aae0-b31cb9c3a699",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 213,
"height": 180,
"rawWidth": 213,
"rawHeight": 180,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "4aae83cf-809c-4556-86f0-08bfefacc909",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 886,
"height": 16,
"platformSettings": {},
"subMetas": {
"pbbg1": {
"ver": "1.0.4",
"uuid": "1eb8f65f-e646-43ae-8af0-21995ddd351d",
"rawTextureUuid": "4aae83cf-809c-4556-86f0-08bfefacc909",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 886,
"height": 16,
"rawWidth": 886,
"rawHeight": 16,
"borderTop": 4,
"borderBottom": 4,
"borderLeft": 10,
"borderRight": 10,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "65ac1dc4-ec2d-4dce-8e05-d5f8bd54fa36",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 213,
"height": 180,
"platformSettings": {},
"subMetas": {
"play": {
"ver": "1.0.4",
"uuid": "9b421b39-8aa4-4e39-bfb5-a2f7325df219",
"rawTextureUuid": "65ac1dc4-ec2d-4dce-8e05-d5f8bd54fa36",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 213,
"height": 180,
"rawWidth": 213,
"rawHeight": 180,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "0e014438-2aac-418d-8ab1-a934a0c00bba",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 141,
"height": 171,
"platformSettings": {},
"subMetas": {
"replay": {
"ver": "1.0.4",
"uuid": "84e9a926-e72c-47b2-9f49-36279947554d",
"rawTextureUuid": "0e014438-2aac-418d-8ab1-a934a0c00bba",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 141,
"height": 171,
"rawWidth": 141,
"rawHeight": 171,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"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": {}
}
}
}
\ No newline at end of file
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
"height": 50, "height": 50,
"rawWidth": 744, "rawWidth": 744,
"rawHeight": 50, "rawHeight": 50,
"borderTop": 0, "borderTop": 15,
"borderBottom": 0, "borderBottom": 21,
"borderLeft": 35, "borderLeft": 35,
"borderRight": 37, "borderRight": 37,
"subMetas": {} "subMetas": {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment