Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fyge_for_tb
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王剑峰
fyge_for_tb
Commits
85298eab
Commit
85298eab
authored
May 01, 2020
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
eb22fbd4
Changes
20
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
431 additions
and
145 deletions
+431
-145
.gitignore
.gitignore
+1
-0
fyge.min.js
dist/fyge.min.js
+1
-1
fyge.min.js.map
dist/fyge.min.js.map
+1
-1
const.ts
src/2d/const.ts
+18
-7
Container.ts
src/2d/display/Container.ts
+3
-3
Stage.ts
src/2d/display/Stage.ts
+2
-2
EventDispatcher.ts
src/2d/events/EventDispatcher.ts
+7
-5
Graphics.ts
src/2d/graphics/Graphics.ts
+35
-35
Loader.ts
src/2d/loader/Loader.ts
+2
-1
CanvasRenderer.ts
src/2d/renderers/CanvasRenderer.ts
+15
-4
CanvasRenderTarget.ts
src/2d/renderers/renderTarget/CanvasRenderTarget.ts
+3
-3
TextField.ts
src/2d/text/TextField.ts
+51
-42
Texture.ts
src/2d/texture/Texture.ts
+1
-1
tbminiAdapte.ts
src/2d/utils/tbminiAdapte.ts
+4
-6
toDisplayDataURL.ts
src/2d/utils/toDisplayDataURL.ts
+2
-1
Stats.ts
src/Stats.ts
+33
-16
Stats1.ts
src/Stats1.ts
+102
-0
index.ts
src/index.ts
+1
-0
SoundChannel.ts
src/sound/SoundChannel.ts
+1
-1
FYGE.d.ts
types/FYGE.d.ts
+148
-16
No files found.
.gitignore
View file @
85298eab
# project ignores
# project ignores
node_modules
node_modules
jsconfig111111.json
\ No newline at end of file
dist/fyge.min.js
View file @
85298eab
This source diff could not be displayed because it is too large. You can
view the blob
instead.
dist/fyge.min.js.map
View file @
85298eab
This diff is collapsed.
Click to expand it.
src/2d/const.ts
View file @
85298eab
...
@@ -9,21 +9,32 @@
...
@@ -9,21 +9,32 @@
*/
*/
export
const
VERSION
=
"1.0"
;
export
const
VERSION
=
"1.0"
;
/**
/**
*
有问题
*
判读window,标记浏览器环境,到时万一淘宝小程序内也有window,再改
*/
*/
//@ts-ignore
//@ts-ignore
export
const
sysInfo
=
my
.
getSystemInfoSync
();
export
const
devicePixelRatio
:
number
=
window
&&
(
window
.
devicePixelRatio
||
1
)
||
my
.
getSystemInfoSync
().
pixelRatio
;
/**
* 有问题
*/
export
const
devicePixelRatio
:
number
=
sysInfo
.
pixelRatio
//window.devicePixelRatio || 1;
/**
/**
* 获取设备号iOS Android
* 获取设备号iOS Android
* 先判断浏览器环境设备号,没有就是小程序环境
*/
*/
export
const
osType
:
"ios"
|
"android"
=
sysInfo
.
platform
.
toLowerCase
()
export
const
osType
:
"ios"
|
"android"
|
"pc"
=
navigator
&&
navigator
.
userAgent
&&
(
function
()
{
let
n
=
navigator
.
userAgent
.
toLocaleLowerCase
();
let
reg1
=
/android/
;
let
reg2
=
/iphone|ipod|ipad/
;
if
(
reg1
.
test
(
n
))
{
return
"android"
;
}
else
if
(
reg2
.
test
(
n
))
{
return
"ios"
}
else
{
return
"pc"
;
}
})()
//@ts-ignore
||
my
.
getSystemInfoSync
().
platform
.
toLowerCase
()
let
PI
:
number
=
Math
.
PI
;
let
PI
:
number
=
Math
.
PI
;
...
...
src/2d/display/Container.ts
View file @
85298eab
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
{
DisplayObject
}
from
'./DisplayObject'
;
import
{
DisplayObject
}
from
'./DisplayObject'
;
import
{
Rectangle
}
from
"../math/Rectangle"
;
import
{
Rectangle
}
from
"../math/Rectangle"
;
import
{
Point
}
from
'../math'
;
import
{
Point
}
from
'../math'
;
import
{
CanvasRenderer
}
from
'../renderers/CanvasRenderer'
;
import
{
CanvasRenderer
}
from
'../renderers/CanvasRenderer'
;
import
{
Event
}
from
"../events/Event"
import
{
Event
}
from
"../events/Event"
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
/**
/**
...
@@ -49,7 +49,7 @@ export default class Container extends DisplayObject {
...
@@ -49,7 +49,7 @@ export default class Container extends DisplayObject {
* @param {DisplayObject} child
* @param {DisplayObject} child
* @return {DisplayObject}
* @return {DisplayObject}
*/
*/
addChild
(
child
:
DisplayObject
):
DisplayObject
{
addChild
<
T
extends
DisplayObject
>
(
child
:
T
):
T
{
//默认添加在最顶层
//默认添加在最顶层
this
.
addChildAt
(
child
,
this
.
children
.
length
);
this
.
addChildAt
(
child
,
this
.
children
.
length
);
return
child
;
return
child
;
...
@@ -61,7 +61,7 @@ export default class Container extends DisplayObject {
...
@@ -61,7 +61,7 @@ export default class Container extends DisplayObject {
* @param {number} index - The index to place the child in
* @param {number} index - The index to place the child in
* @return {DisplayObject} The child that was added.
* @return {DisplayObject} The child that was added.
*/
*/
addChildAt
(
child
:
DisplayObject
,
index
:
number
):
DisplayObject
{
addChildAt
<
T
extends
DisplayObject
>
(
child
:
T
,
index
:
number
):
T
{
if
(
!
child
)
return
;
if
(
!
child
)
return
;
let
s
=
this
;
let
s
=
this
;
...
...
src/2d/display/Stage.ts
View file @
85298eab
...
@@ -342,8 +342,8 @@ export class Stage extends Container {
...
@@ -342,8 +342,8 @@ export class Stage extends Container {
}
else
{
}
else
{
cp
=
new
Point
();
cp
=
new
Point
();
}
}
cp
.
x
=
(
points
[
o
].
x
||
points
[
o
].
b
)
*
s
.
dpi
// devicePixelRatio;
cp
.
x
=
(
points
[
o
].
pageX
||
points
[
o
].
x
||
points
[
o
].
b
)
*
s
.
dpi
// devicePixelRatio;
cp
.
y
=
(
points
[
o
].
y
||
points
[
o
].
c
)
*
s
.
dpi
// devicePixelRatio;
cp
.
y
=
(
points
[
o
].
pageY
||
points
[
o
].
y
||
points
[
o
].
c
)
*
s
.
dpi
// devicePixelRatio;
// my.alert({
// my.alert({
// title: JSON.stringify(points[o])
// title: JSON.stringify(points[o])
// });
// });
...
...
src/2d/events/EventDispatcher.ts
View file @
85298eab
...
@@ -73,7 +73,7 @@ export class EventDispatcher extends HashObject {
...
@@ -73,7 +73,7 @@ export class EventDispatcher extends HashObject {
* @example
* @example
* this.addEventListener(Event.ADD_TO_STAGE,function(e){trace(this);},this);
* this.addEventListener(Event.ADD_TO_STAGE,function(e){trace(this);},this);
*/
*/
public
addEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
:
boolean
=
true
):
void
{
public
addEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
:
boolean
=
true
):
this
{
if
(
!
type
)
{
if
(
!
type
)
{
throw
new
Error
(
"添加侦听的type值为undefined"
);
throw
new
Error
(
"添加侦听的type值为undefined"
);
}
}
...
@@ -99,14 +99,14 @@ export class EventDispatcher extends HashObject {
...
@@ -99,14 +99,14 @@ export class EventDispatcher extends HashObject {
let
ee
:
EE
=
eventTypes
[
type
][
i
]
let
ee
:
EE
=
eventTypes
[
type
][
i
]
if
(
ee
.
fn
===
listener
&&
ee
.
context
===
context
)
{
if
(
ee
.
fn
===
listener
&&
ee
.
context
===
context
)
{
console
.
log
(
"已添加过该事件"
)
console
.
log
(
"已添加过该事件"
)
return
return
s
}
}
}
}
eventTypes
[
type
].
unshift
(
new
EE
(
listener
,
context
||
s
));
eventTypes
[
type
].
unshift
(
new
EE
(
listener
,
context
||
s
));
if
(
type
.
indexOf
(
"onMouse"
)
==
0
)
{
if
(
type
.
indexOf
(
"onMouse"
)
==
0
)
{
s
.
_changeMouseCount
(
type
,
true
);
s
.
_changeMouseCount
(
type
,
true
);
}
}
return
s
}
}
/**
/**
...
@@ -116,7 +116,7 @@ export class EventDispatcher extends HashObject {
...
@@ -116,7 +116,7 @@ export class EventDispatcher extends HashObject {
* @param context
* @param context
* @param useCapture
* @param useCapture
*/
*/
public
once
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
:
boolean
=
true
):
void
{
public
once
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
:
boolean
=
true
):
this
{
if
(
!
type
)
{
if
(
!
type
)
{
throw
new
Error
(
"添加侦听的type值为undefined"
);
throw
new
Error
(
"添加侦听的type值为undefined"
);
}
}
...
@@ -136,6 +136,7 @@ export class EventDispatcher extends HashObject {
...
@@ -136,6 +136,7 @@ export class EventDispatcher extends HashObject {
if
(
type
.
indexOf
(
"onMouse"
)
==
0
)
{
if
(
type
.
indexOf
(
"onMouse"
)
==
0
)
{
s
.
_changeMouseCount
(
type
,
true
);
s
.
_changeMouseCount
(
type
,
true
);
}
}
return
s
}
}
/**
/**
...
@@ -255,7 +256,7 @@ export class EventDispatcher extends HashObject {
...
@@ -255,7 +256,7 @@ export class EventDispatcher extends HashObject {
* @param context listener和context都相等的才移除,默认自身
* @param context listener和context都相等的才移除,默认自身
* @param {boolean} useCapture true 捕获阶段 false 冒泡阶段 默认 true
* @param {boolean} useCapture true 捕获阶段 false 冒泡阶段 默认 true
*/
*/
public
removeEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
:
boolean
=
true
):
void
{
public
removeEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
:
boolean
=
true
):
this
{
let
s
=
this
;
let
s
=
this
;
let
listeners
:
EE
[]
=
s
.
eventTypes
[
type
];
let
listeners
:
EE
[]
=
s
.
eventTypes
[
type
];
if
(
!
useCapture
)
{
if
(
!
useCapture
)
{
...
@@ -279,6 +280,7 @@ export class EventDispatcher extends HashObject {
...
@@ -279,6 +280,7 @@ export class EventDispatcher extends HashObject {
// }
// }
}
}
}
}
return
s
}
}
/**
/**
...
...
src/2d/graphics/Graphics.ts
View file @
85298eab
...
@@ -8,7 +8,7 @@ import { sign, string2hex, hex2rgb } from '../utils';
...
@@ -8,7 +8,7 @@ import { sign, string2hex, hex2rgb } from '../utils';
import
{
SHAPES
,
PI_2
,
SCALE_MODES
,
WRAP_MODES
,
BLEND_MODES
}
from
'../const'
;
import
{
SHAPES
,
PI_2
,
SCALE_MODES
,
WRAP_MODES
,
BLEND_MODES
}
from
'../const'
;
import
{
DisplayObject
}
from
'../display/DisplayObject'
;
import
{
DisplayObject
}
from
'../display/DisplayObject'
;
import
Texture
from
'../texture/Texture'
;
import
Texture
from
'../texture/Texture'
;
import
{
CanvasRenderer
}
from
'../renderers/CanvasRenderer'
;
import
{
CanvasRenderer
}
from
'../renderers/CanvasRenderer'
;
import
{
Event
}
from
"../events/Event"
import
{
Event
}
from
"../events/Event"
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
{
WebglRenderer
}
from
'../renderers/WebglRenderer'
;
import
buildPoly
from
'./geomBuild/buildPoly'
;
import
buildPoly
from
'./geomBuild/buildPoly'
;
...
@@ -20,7 +20,7 @@ import FillStyle from './styles/FillStyle';
...
@@ -20,7 +20,7 @@ import FillStyle from './styles/FillStyle';
import
LineStyle
from
'./styles/LineStyle'
;
import
LineStyle
from
'./styles/LineStyle'
;
import
{
GRAPHICS_CURVES
,
quadraticCurveLength
,
bezierCurveLength
,
bezierCurveTo
}
from
'./utils'
;
import
{
GRAPHICS_CURVES
,
quadraticCurveLength
,
bezierCurveLength
,
bezierCurveTo
}
from
'./utils'
;
import
Container
from
'../display/Container'
;
import
Container
from
'../display/Container'
;
let
canvasRenderer
:
CanvasRenderer
;
const
tempMatrix
=
new
Matrix
();
const
tempMatrix
=
new
Matrix
();
const
tempPoint
=
new
Point
();
const
tempPoint
=
new
Point
();
const
tempColor1
=
new
Float32Array
(
4
);
const
tempColor1
=
new
Float32Array
(
4
);
...
@@ -1353,39 +1353,39 @@ export default class Graphics extends Container {
...
@@ -1353,39 +1353,39 @@ export default class Graphics extends Container {
* @return {Texture} The new texture.
* @return {Texture} The new texture.
*/
*/
private
generateCanvasTexture
(
scaleMode
:
number
=
SCALE_MODES
.
LINEAR
):
Texture
{
private
generateCanvasTexture
(
scaleMode
:
number
=
SCALE_MODES
.
LINEAR
):
Texture
{
//
this.updateLocalBoundsSelf();
this
.
updateLocalBoundsSelf
();
//
const bounds = this._localBoundsSelf;
const
bounds
=
this
.
_localBoundsSelf
;
//
if (!this._canvasBuffer) {
if
(
!
this
.
_canvasBuffer
)
{
//
this._canvasBuffer = RenderTexture.create(bounds.width, bounds.height, scaleMode);
this
.
_canvasBuffer
=
RenderTexture
.
create
(
bounds
.
width
,
bounds
.
height
,
scaleMode
);
//
} else {
}
else
{
//
this._canvasBuffer.resize(bounds.width, bounds.height)
this
.
_canvasBuffer
.
resize
(
bounds
.
width
,
bounds
.
height
)
//
}
}
//
if (!canvasRenderer) {
if
(
!
canvasRenderer
)
{
// canvasRenderer = new CanvasRenderer({}
);
canvasRenderer
=
new
CanvasRenderer
(
null
,
0
,
0
);
//
}
}
//
this.transform.updateLocalMatrix();
this
.
transform
.
updateLocalMatrix
();
//
tempMatrix.copy(this.transform.localMatrix);
tempMatrix
.
copy
(
this
.
transform
.
localMatrix
);
//
tempMatrix.invert();
tempMatrix
.
invert
();
//
tempMatrix.tx -= bounds.x;
tempMatrix
.
tx
-=
bounds
.
x
;
//
tempMatrix.ty -= bounds.y;
tempMatrix
.
ty
-=
bounds
.
y
;
//
canvasRenderer.render(this, this._canvasBuffer, tempMatrix);
canvasRenderer
.
render
(
this
,
this
.
_canvasBuffer
,
tempMatrix
);
//
//
document.body.appendChild(this._canvasBuffer.baseTexture["_canvasRenderTarget"].canvas)
// document.body.appendChild(this._canvasBuffer.baseTexture["_canvasRenderTarget"].canvas)
//
if (!this._texture) {
if
(
!
this
.
_texture
)
{
// this._texture = Texture.fromCanvas(this._canvasBuffer.baseTexture["_canvasRenderTarget"].canvas, scaleMode
, 'graphics');
this
.
_texture
=
Texture
.
fromCanvas
(
this
.
_canvasBuffer
.
baseTexture
[
"_canvasRenderTarget"
].
canvas
,
'graphics'
);
//
this._texture.baseTexture.update();
this
.
_texture
.
baseTexture
.
update
();
//
} else {
}
else
{
//
this._texture.baseTexture.update();
this
.
_texture
.
baseTexture
.
update
();
//
}
}
//
//
可能需要更改_texture,this._texture.baseTexture尺寸
//可能需要更改_texture,this._texture.baseTexture尺寸
//
this.offsetX = bounds.x;
this
.
offsetX
=
bounds
.
x
;
//
this.offsetY = bounds.y;
this
.
offsetY
=
bounds
.
y
;
//
return this._texture;
return
this
.
_texture
;
return
//
return
}
}
/**
/**
...
...
src/2d/loader/Loader.ts
View file @
85298eab
...
@@ -74,7 +74,8 @@ export class Loader extends EventDispatcher {
...
@@ -74,7 +74,8 @@ export class Loader extends EventDispatcher {
// })
// })
}
}
loadJson
(
callback
,
url
)
{
loadJson
(
callback
,
url
)
{
window
[
"my"
].
request
({
//@ts-ignore
my
.
request
({
url
:
url
,
url
:
url
,
dataType
:
"json"
,
dataType
:
"json"
,
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
...
...
src/2d/renderers/CanvasRenderer.ts
View file @
85298eab
...
@@ -15,6 +15,13 @@ import { mapCanvasBlendModes } from "../utils";
...
@@ -15,6 +15,13 @@ import { mapCanvasBlendModes } from "../utils";
* 暂时不用,用时再说
* 暂时不用,用时再说
*/
*/
export
class
CanvasRenderer
extends
SystemRenderer
{
export
class
CanvasRenderer
extends
SystemRenderer
{
/**
* 主屏幕渲染上下文
*/
rootContext
:
CanvasRenderingContext2D
;
/**
* 当前使用的上下文
*/
context
:
CanvasRenderingContext2D
;
context
:
CanvasRenderingContext2D
;
/**
/**
* 遮罩管理类
* 遮罩管理类
...
@@ -43,7 +50,7 @@ export class CanvasRenderer extends SystemRenderer {
...
@@ -43,7 +50,7 @@ export class CanvasRenderer extends SystemRenderer {
this
.
type
=
RENDERER_TYPE
.
CANVAS
this
.
type
=
RENDERER_TYPE
.
CANVAS
this
.
_instanceType
=
"CanvasRenderer"
;
this
.
_instanceType
=
"CanvasRenderer"
;
this
.
c
ontext
=
context
;
this
.
rootC
ontext
=
context
;
this
.
maskManager
=
new
CanvasMaskManager
(
this
);
this
.
maskManager
=
new
CanvasMaskManager
(
this
);
...
@@ -73,8 +80,7 @@ export class CanvasRenderer extends SystemRenderer {
...
@@ -73,8 +80,7 @@ export class CanvasRenderer extends SystemRenderer {
//渲染开始前触发
//渲染开始前触发
this
.
dispatchEvent
(
'prerender'
);
this
.
dispatchEvent
(
'prerender'
);
//
let
context
=
this
.
context
;
//是否渲染到主屏幕
//是否渲染到主屏幕
let
renderingToScreen
=
!
renderTexture
;
let
renderingToScreen
=
!
renderTexture
;
if
(
renderTexture
)
{
if
(
renderTexture
)
{
...
@@ -92,9 +98,14 @@ export class CanvasRenderer extends SystemRenderer {
...
@@ -92,9 +98,14 @@ export class CanvasRenderer extends SystemRenderer {
renderTexture
.
_canvasRenderTarget
.
resize
(
renderTexture
.
width
,
renderTexture
.
height
);
renderTexture
.
_canvasRenderTarget
.
resize
(
renderTexture
.
width
,
renderTexture
.
height
);
}
}
//当前上下文要修改成离屏的
//当前上下文要修改成离屏的
context
=
renderTexture
.
_canvasRenderTarget
.
context
;
this
.
context
=
renderTexture
.
_canvasRenderTarget
.
context
;
}
else
{
//当前上下文就是根节点的
this
.
context
=
this
.
rootContext
;
}
}
const
context
=
this
.
context
;
if
(
!
renderTexture
)
{
if
(
!
renderTexture
)
{
this
.
_lastObjectRendered
=
displayObject
;
this
.
_lastObjectRendered
=
displayObject
;
}
}
...
...
src/2d/renderers/renderTarget/CanvasRenderTarget.ts
View file @
85298eab
...
@@ -21,10 +21,10 @@ export default class CanvasRenderTarget {
...
@@ -21,10 +21,10 @@ export default class CanvasRenderTarget {
constructor
(
width
:
number
,
height
:
number
)
{
constructor
(
width
:
number
,
height
:
number
)
{
this
.
canvas
=
createCanvas
()
//document.createElement('canvas');
this
.
canvas
=
createCanvas
()
//document.createElement('canvas');
// console.log("rd1",this.canvas)
this
.
resize
(
width
,
height
);
//要先设置尺寸?
this
.
context
=
this
.
canvas
.
getContext
(
'2d'
);
this
.
context
=
this
.
canvas
.
getContext
(
'2d'
);
// console.log("rd",this.context)
this
.
resize
(
width
,
height
);
this
.
resize
(
width
,
height
);
}
}
...
...
src/2d/text/TextField.ts
View file @
85298eab
...
@@ -33,33 +33,39 @@ export class TextField extends Sprite {
...
@@ -33,33 +33,39 @@ export class TextField extends Sprite {
super
();
super
();
this
.
_instanceType
=
"TextField"
;
this
.
_instanceType
=
"TextField"
;
//ios直接
//ios直接
if
(
osType
==
"ios"
)
{
//
if (osType == "ios") {
var
canvas
=
createCanvas
()
var
canvas
=
createCanvas
()
canvas
.
width
=
3
;
// canvas.width = 3;
canvas
.
height
=
3
;
// canvas.height = 3;
if
(
osType
==
"ios"
)
{
canvas
.
width
=
canvas
.
height
=
3
;
}
else
{
//现在只能用canvas2d渲染,所以不能用imageData了,等修复了安卓canvas尺寸问题再改
canvas
.
width
=
300
;
canvas
.
height
=
150
;
}
this
.
texture
=
Texture
.
fromCanvas
(
canvas
,
"textCanvas"
);
this
.
texture
=
Texture
.
fromCanvas
(
canvas
,
"textCanvas"
);
this
.
canvas
=
canvas
;
this
.
canvas
=
canvas
;
this
.
context
=
canvas
.
getContext
(
"2d"
);
this
.
context
=
canvas
.
getContext
(
"2d"
);
}
//
}
//安卓的不能改变离屏canvas的尺寸,所以用750*750的,取imageData
//
//
安卓的不能改变离屏canvas的尺寸,所以用750*750的,取imageData
else
{
//
else {
if
(
!
TextField
.
shareCanvas
)
{
//
if (!TextField.shareCanvas) {
TextField
.
shareCanvas
=
createCanvas
();
//
TextField.shareCanvas = createCanvas();
TextField
.
shareCanvas
.
width
=
TextField
.
shareCanvas
.
height
=
750
;
//
TextField.shareCanvas.width = TextField.shareCanvas.height = 750;
TextField
.
shareContext
=
TextField
.
shareCanvas
.
getContext
(
"2d"
);
//
TextField.shareContext = TextField.shareCanvas.getContext("2d");
}
//
}
var
baseTexture
=
new
BaseTexture
({
//
var baseTexture = new BaseTexture({
data
:
[],
//
data: [],
width
:
0
,
//
width: 0,
height
:
0
,
//
height: 0,
type
:
"text"
,
//
type: "text",
path
:
null
//
path: null
});
//
});
this
.
texture
=
new
Texture
(
baseTexture
);
//
this.texture = new Texture(baseTexture);
this
.
canvas
=
TextField
.
shareCanvas
;
//
this.canvas = TextField.shareCanvas;
this
.
context
=
TextField
.
shareContext
;
//
this.context = TextField.shareContext;
}
//
}
//baseTexture已自动缓存,把texture也缓存,key textCanvas+num 和baseTexture的一致
//baseTexture已自动缓存,把texture也缓存,key textCanvas+num 和baseTexture的一致
Texture
.
addToCache
(
this
.
texture
,
this
.
texture
.
baseTexture
.
textureCacheIds
[
0
]);
Texture
.
addToCache
(
this
.
texture
,
this
.
texture
.
baseTexture
.
textureCacheIds
[
0
]);
...
@@ -488,7 +494,7 @@ export class TextField extends Sprite {
...
@@ -488,7 +494,7 @@ export class TextField extends Sprite {
if
(
osType
==
"ios"
)
{
if
(
osType
==
"ios"
)
{
s
.
canvas
.
width
=
0
;
s
.
canvas
.
width
=
0
;
s
.
canvas
.
height
=
0
;
s
.
canvas
.
height
=
0
;
}
else
{
}
else
{
//暂时不能用sourceData形式,所以和上面效果一样
s
.
texture
.
baseTexture
.
source
.
width
=
0
;
s
.
texture
.
baseTexture
.
source
.
width
=
0
;
s
.
texture
.
baseTexture
.
source
.
height
=
0
;
s
.
texture
.
baseTexture
.
source
.
height
=
0
;
}
}
...
@@ -598,33 +604,36 @@ export class TextField extends Sprite {
...
@@ -598,33 +604,36 @@ export class TextField extends Sprite {
}
}
}
}
for
(
let
i
=
0
;
i
<
realLines
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
realLines
.
length
;
i
++
)
{
let
ox
=
0
;
//@ts-ignore 现在貌似小程序的textAlign有点问题,如果修复了再说
if
(
my
)
ox
=
-
tx
;
//移回去
if
(
s
.
stroke
)
{
if
(
s
.
stroke
)
{
ctx
.
strokeStyle
=
s
.
strokeColor
;
ctx
.
strokeStyle
=
s
.
strokeColor
;
ctx
.
lineWidth
=
s
.
stroke
*
2
;
ctx
.
lineWidth
=
s
.
stroke
*
2
;
ctx
.
strokeText
(
realLines
[
i
],
0
,
upY
+
i
*
lineH
,
maxW
);
ctx
.
strokeText
(
realLines
[
i
],
ox
,
upY
+
i
*
lineH
,
maxW
);
}
}
ctx
.
fillText
(
realLines
[
i
],
0
,
upY
+
i
*
lineH
,
maxW
);
ctx
.
fillText
(
realLines
[
i
],
ox
,
upY
+
i
*
lineH
,
maxW
);
}
}
//offset用_anchorTexture代替
//offset用_anchorTexture代替
s
.
offsetX
=
-
padding
;
s
.
offsetX
=
-
padding
;
s
.
offsetY
=
-
padding
;
s
.
offsetY
=
-
padding
;
// console.log(can)
// console.log(can)
this
.
anchorTexture
=
{
x
:
(
padding
+
0.5
)
/
canWidth
,
y
:
padding
/
canHeight
}
this
.
anchorTexture
=
{
x
:
(
padding
+
0.5
)
/
canWidth
,
y
:
padding
/
canHeight
}
if
(
osType
==
"ios"
)
{
//
if (osType == "ios") {
s
.
texture
.
update
();
s
.
texture
.
update
();
s
.
_onTextureUpdate
();
s
.
_onTextureUpdate
();
}
else
{
//
} else {
var
imgData
=
ctx
.
getImageData
(
0
,
0
,
canWidth
,
canHeight
)
//
var imgData = ctx.getImageData(0, 0, canWidth, canHeight)
var
data
=
{
//
var data = {
data
:
new
Uint8Array
(
imgData
.
data
),
//
data: new Uint8Array(imgData.data),
width
:
canWidth
,
//
width: canWidth,
height
:
canHeight
,
//
height: canHeight,
type
:
"text"
,
//
type: "text",
path
:
null
//
path: null
}
//
}
s
.
texture
.
baseTexture
.
_sourceChange
(
data
);
//
s.texture.baseTexture._sourceChange(data);
s
.
_onTextureUpdate
();
//
s._onTextureUpdate();
}
//
}
}
}
...
...
src/2d/texture/Texture.ts
View file @
85298eab
...
@@ -142,7 +142,7 @@ export default class Texture extends EventDispatcher {
...
@@ -142,7 +142,7 @@ export default class Texture extends EventDispatcher {
this
.
_rotate
=
Number
(
rotate
||
0
);
this
.
_rotate
=
Number
(
rotate
||
0
);
if
(
baseTexture
.
hasLoaded
)
{
if
(
baseTexture
.
hasLoaded
)
{
//对于canvas形式的判断hasLoaded有问题,导致不能监听update,到时改
if
(
this
.
noFrame
)
{
if
(
this
.
noFrame
)
{
frame
=
new
Rectangle
(
0
,
0
,
baseTexture
.
width
,
baseTexture
.
height
);
frame
=
new
Rectangle
(
0
,
0
,
baseTexture
.
width
,
baseTexture
.
height
);
// if there is no frame we should monitor for any base texture changes..
// if there is no frame we should monitor for any base texture changes..
...
...
src/2d/utils/tbminiAdapte.ts
View file @
85298eab
/**
* ios还有问题,先别用
*/
export
function
createCanvas
():
HTMLCanvasElement
{
export
function
createCanvas
():
HTMLCanvasElement
{
//@ts-ignore
//@ts-ignore
return
my
&&
my
.
_createOffscreenCanvas
()
||
document
.
createElement
(
"canvas"
)
return
document
&&
document
.
createElement
(
"canvas"
)
||
my
.
_createOffscreenCanvas
()
||
document
.
createElement
(
"canvas"
)
}
}
//每次都要重置
//每次都要重置
let
backupCanvasContext
:
CanvasRenderingContext2D
let
backupCanvasContext
:
CanvasRenderingContext2D
...
@@ -48,8 +46,8 @@ export function getCreateImage() {
...
@@ -48,8 +46,8 @@ export function getCreateImage() {
return
contentByCanvas
&&
contentByCanvas
.
createImage
||
(()
=>
{
return
new
Image
()
})
return
contentByCanvas
&&
contentByCanvas
.
createImage
||
(()
=>
{
return
new
Image
()
})
}
}
export
function
getRequestAnimationFrame
()
{
export
function
getRequestAnimationFrame
()
{
return
contentByCanvas
&&
contentByCanvas
.
requestAnimationFrame
||
window
.
requestAnimationFrame
return
contentByCanvas
&&
contentByCanvas
.
requestAnimationFrame
||
window
.
requestAnimationFrame
.
bind
(
window
)
}
}
export
function
getCancelAnimationFrame
()
{
export
function
getCancelAnimationFrame
()
{
return
contentByCanvas
&&
contentByCanvas
.
cancelAnimationFrame
||
window
.
cancelAnimationFrame
return
contentByCanvas
&&
contentByCanvas
.
cancelAnimationFrame
||
window
.
cancelAnimationFrame
.
bind
(
window
)
}
}
src/2d/utils/toDisplayDataURL.ts
View file @
85298eab
...
@@ -2,6 +2,7 @@ import { CanvasRenderer } from "../renderers/CanvasRenderer";
...
@@ -2,6 +2,7 @@ import { CanvasRenderer } from "../renderers/CanvasRenderer";
import
RenderTexture
from
"../texture/RenderTexture"
;
import
RenderTexture
from
"../texture/RenderTexture"
;
import
{
Matrix
,
Rectangle
}
from
"../math"
;
import
{
Matrix
,
Rectangle
}
from
"../math"
;
import
{
DisplayObject
}
from
"../display/DisplayObject"
;
import
{
DisplayObject
}
from
"../display/DisplayObject"
;
import
{
createCanvas
}
from
"./tbminiAdapte"
;
// 作为将显示对象导出成图片的render渲染器
// 作为将显示对象导出成图片的render渲染器
let
_dRender
:
CanvasRenderer
=
null
;
let
_dRender
:
CanvasRenderer
=
null
;
...
@@ -37,7 +38,7 @@ export default function toDisplayDataURL(obj: DisplayObject, rect: Rectangle = n
...
@@ -37,7 +38,7 @@ export default function toDisplayDataURL(obj: DisplayObject, rect: Rectangle = n
let
x
:
number
=
rect
?
rect
.
x
:
bounds
.
x
;
let
x
:
number
=
rect
?
rect
.
x
:
bounds
.
x
;
let
y
:
number
=
rect
?
rect
.
y
:
bounds
.
y
;
let
y
:
number
=
rect
?
rect
.
y
:
bounds
.
y
;
if
(
!
_dRender
)
{
if
(
!
_dRender
)
{
var
canvas
:
HTMLCanvasElement
=
window
[
"my"
].
createOffscreen
Canvas
();
var
canvas
:
HTMLCanvasElement
=
create
Canvas
();
canvas
.
width
=
w
;
canvas
.
width
=
w
;
canvas
.
height
=
h
;
canvas
.
height
=
h
;
_dCanvas
=
canvas
_dCanvas
=
canvas
...
...
src/Stats.ts
View file @
85298eab
...
@@ -34,7 +34,7 @@ var Stats = function (canvasId) {
...
@@ -34,7 +34,7 @@ var Stats = function (canvasId) {
//@ts-ignore
//@ts-ignore
Stats
.
Panel
=
function
(
canvasId
,
name
,
fg
,
bg
)
{
Stats
.
Panel
=
function
(
canvasId
,
name
,
fg
,
bg
)
{
var
min
=
Infinity
,
max
=
0
,
round
=
Math
.
round
;
var
min
=
Infinity
,
max
=
0
,
round
=
Math
.
round
;
var
PR
=
1
;
var
PR
=
3
;
var
WIDTH
=
80
*
PR
,
HEIGHT
=
48
*
PR
,
var
WIDTH
=
80
*
PR
,
HEIGHT
=
48
*
PR
,
TEXT_X
=
3
*
PR
,
TEXT_Y
=
2
*
PR
,
TEXT_X
=
3
*
PR
,
TEXT_Y
=
2
*
PR
,
...
@@ -44,13 +44,21 @@ Stats.Panel = function (canvasId, name, fg, bg) {
...
@@ -44,13 +44,21 @@ Stats.Panel = function (canvasId, name, fg, bg) {
var
GRAPH_SIZE
=
GRAPH_WIDTH
/
PR
;
var
GRAPH_SIZE
=
GRAPH_WIDTH
/
PR
;
var
items
=
[];
var
items
=
[];
var
context
//= my.createCanvasContext(canvasId);
//@ts-ignore
//@ts-ignore
var
context
=
my
.
createCanvasContext
(
canvasId
);
my
.
createCanvas
({
id
:
canvasId
,
success
:
(
ccc
)
=>
{
context
=
ccc
.
getContext
(
"2d"
)
context
.
font
=
'bold '
+
(
9
*
PR
)
+
'px Helvetica,Arial,sans-serif'
;
context
.
font
=
'bold '
+
(
9
*
PR
)
+
'px Helvetica,Arial,sans-serif'
;
context
.
setTextBaseline
(
'top'
);
//
context.setTextBaseline('top');
context
.
textBaseline
=
'top'
drawWithoutGraph
(
name
);
drawWithoutGraph
(
name
);
context
.
draw
();
// context.draw();
}
})
return
{
return
{
update
:
function
(
value
,
maxValue
)
{
update
:
function
(
value
,
maxValue
)
{
...
@@ -68,33 +76,42 @@ Stats.Panel = function (canvasId, name, fg, bg) {
...
@@ -68,33 +76,42 @@ Stats.Panel = function (canvasId, name, fg, bg) {
for
(
var
i
=
0
;
i
<
items
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
items
.
length
;
i
++
)
{
var
startPos
=
GRAPH_X
+
(
i
+
GRAPH_SIZE
-
items
.
length
)
*
PR
;
var
startPos
=
GRAPH_X
+
(
i
+
GRAPH_SIZE
-
items
.
length
)
*
PR
;
context
.
setFillStyle
(
fg
);
// context.setFillStyle(fg);
context
.
setGlobalAlpha
(
1
);
// context.setGlobalAlpha(1);
context
.
fillStyle
=
fg
;
context
.
globalAlpha
=
1
;
context
.
fillRect
(
startPos
,
GRAPH_Y
,
PR
,
GRAPH_HEIGHT
);
context
.
fillRect
(
startPos
,
GRAPH_Y
,
PR
,
GRAPH_HEIGHT
);
context
.
setFillStyle
(
bg
);
// context.setFillStyle(bg);
context
.
setGlobalAlpha
(
0.9
);
// context.setGlobalAlpha(0.9);
context
.
fillStyle
=
bg
;
context
.
globalAlpha
=
0.9
;
context
.
fillRect
(
startPos
,
GRAPH_Y
,
PR
,
round
((
1
-
(
items
[
i
]
/
maxValue
))
*
GRAPH_HEIGHT
));
context
.
fillRect
(
startPos
,
GRAPH_Y
,
PR
,
round
((
1
-
(
items
[
i
]
/
maxValue
))
*
GRAPH_HEIGHT
));
}
}
context
.
draw
();
//
context.draw();
}
}
};
};
function
drawWithoutGraph
(
text
)
{
function
drawWithoutGraph
(
text
)
{
// bg
// bg
context
.
setFillStyle
(
bg
);
// context.setFillStyle(bg);
context
.
setGlobalAlpha
(
1
);
// context.setGlobalAlpha(1);
context
.
fillStyle
=
bg
;
context
.
globalAlpha
=
1
;
context
.
fillRect
(
0
,
0
,
WIDTH
,
HEIGHT
);
context
.
fillRect
(
0
,
0
,
WIDTH
,
HEIGHT
);
// text
// text
context
.
setFillStyle
(
fg
);
// context.setFillStyle(fg);
context
.
fillStyle
=
fg
;
context
.
fillText
(
text
,
TEXT_X
,
TEXT_Y
);
context
.
fillText
(
text
,
TEXT_X
,
TEXT_Y
);
// graph bg
// graph bg
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
context
.
setFillStyle
(
bg
);
// context.setFillStyle(bg);
context
.
setGlobalAlpha
(
0.9
);
// context.setGlobalAlpha(0.9);
context
.
fillStyle
=
bg
;
context
.
globalAlpha
=
0.9
;
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
}
}
};
};
...
...
src/Stats1.ts
0 → 100644
View file @
85298eab
/**
* @author mrdoob / http://mrdoob.com/
*/
var
Stats
=
function
(
canvasId
)
{
var
beginTime
=
Date
.
now
(),
prevTime
=
beginTime
,
frames
=
0
;
//@ts-ignore
var
fpsPanel
=
new
Stats
.
Panel
(
canvasId
,
'FPS'
,
'#0ff'
,
'#002'
);
return
{
begin
:
function
()
{
beginTime
=
Date
.
now
();
},
end
:
function
()
{
frames
++
;
var
time
=
Date
.
now
();
if
(
time
>=
prevTime
+
1000
)
{
fpsPanel
.
update
((
frames
*
1000
)
/
(
time
-
prevTime
),
100.0
);
prevTime
=
time
;
frames
=
0
;
}
return
time
;
},
update
:
function
()
{
beginTime
=
this
.
end
();
},
};
};
//@ts-ignore
Stats
.
Panel
=
function
(
canvasId
,
name
,
fg
,
bg
)
{
var
min
=
Infinity
,
max
=
0
,
round
=
Math
.
round
;
var
PR
=
1
;
var
WIDTH
=
80
*
PR
,
HEIGHT
=
48
*
PR
,
TEXT_X
=
3
*
PR
,
TEXT_Y
=
2
*
PR
,
GRAPH_X
=
3
*
PR
,
GRAPH_Y
=
15
*
PR
,
GRAPH_WIDTH
=
74
*
PR
,
GRAPH_HEIGHT
=
30
*
PR
;
var
GRAPH_SIZE
=
GRAPH_WIDTH
/
PR
;
var
items
=
[];
//@ts-ignore
var
context
=
my
.
createCanvasContext
(
canvasId
);
context
.
font
=
'bold '
+
(
9
*
PR
)
+
'px Helvetica,Arial,sans-serif'
;
context
.
setTextBaseline
(
'top'
);
drawWithoutGraph
(
name
);
context
.
draw
();
return
{
update
:
function
(
value
,
maxValue
)
{
items
.
push
(
value
);
while
(
items
.
length
>
GRAPH_SIZE
)
{
items
.
shift
();
}
min
=
Math
.
min
(
min
,
value
);
max
=
Math
.
max
(
max
,
value
);
drawWithoutGraph
(
round
(
value
)
+
' '
+
name
+
' ('
+
round
(
min
)
+
'-'
+
round
(
max
)
+
')'
);
// graph inner
for
(
var
i
=
0
;
i
<
items
.
length
;
i
++
)
{
var
startPos
=
GRAPH_X
+
(
i
+
GRAPH_SIZE
-
items
.
length
)
*
PR
;
context
.
setFillStyle
(
fg
);
context
.
setGlobalAlpha
(
1
);
context
.
fillRect
(
startPos
,
GRAPH_Y
,
PR
,
GRAPH_HEIGHT
);
context
.
setFillStyle
(
bg
);
context
.
setGlobalAlpha
(
0.9
);
context
.
fillRect
(
startPos
,
GRAPH_Y
,
PR
,
round
((
1
-
(
items
[
i
]
/
maxValue
))
*
GRAPH_HEIGHT
));
}
context
.
draw
();
}
};
function
drawWithoutGraph
(
text
)
{
// bg
context
.
setFillStyle
(
bg
);
context
.
setGlobalAlpha
(
1
);
context
.
fillRect
(
0
,
0
,
WIDTH
,
HEIGHT
);
// text
context
.
setFillStyle
(
fg
);
context
.
fillText
(
text
,
TEXT_X
,
TEXT_Y
);
// graph bg
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
context
.
setFillStyle
(
bg
);
context
.
setGlobalAlpha
(
0.9
);
context
.
fillRect
(
GRAPH_X
,
GRAPH_Y
,
GRAPH_WIDTH
,
GRAPH_HEIGHT
);
}
};
export
{
Stats
/*as default*/
};
src/index.ts
View file @
85298eab
...
@@ -37,6 +37,7 @@ export * from "./sound"
...
@@ -37,6 +37,7 @@ export * from "./sound"
export
*
from
"./tween"
;
export
*
from
"./tween"
;
if
(
window
)
window
[
"my"
]
=
null
// export * from "./Stats";
// export * from "./Stats";
/**
/**
...
...
src/sound/SoundChannel.ts
View file @
85298eab
...
@@ -111,7 +111,7 @@ export class SoundChannel extends EventDispatcher {
...
@@ -111,7 +111,7 @@ export class SoundChannel extends EventDispatcher {
let
url
=
this
.
$url
;
let
url
=
this
.
$url
;
//延迟一定时间再停止,规避chrome报错
//延迟一定时间再停止,规避chrome报错
window
.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
audio
.
pause
();
audio
.
pause
();
Sound
.
$recycle
(
url
,
audio
);
Sound
.
$recycle
(
url
,
audio
);
},
200
);
},
200
);
...
...
types/FYGE.d.ts
View file @
85298eab
...
@@ -1227,7 +1227,7 @@ export class EventDispatcher extends HashObject {
...
@@ -1227,7 +1227,7 @@ export class EventDispatcher extends HashObject {
* @example
* @example
* this.addEventListener(Event.ADD_TO_STAGE,function(e){trace(this);},this);
* this.addEventListener(Event.ADD_TO_STAGE,function(e){trace(this);},this);
*/
*/
addEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
?:
boolean
):
void
;
addEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
?:
boolean
):
this
;
/**
/**
* 监听一次
* 监听一次
* @param type
* @param type
...
@@ -1235,7 +1235,7 @@ export class EventDispatcher extends HashObject {
...
@@ -1235,7 +1235,7 @@ export class EventDispatcher extends HashObject {
* @param context
* @param context
* @param useCapture
* @param useCapture
*/
*/
once
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
?:
boolean
):
void
;
once
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
?:
boolean
):
this
;
/**
/**
* 增加或删除相应mouse或touch侦听记数
* 增加或删除相应mouse或touch侦听记数
* @method _changeMouseCount
* @method _changeMouseCount
...
@@ -1285,7 +1285,7 @@ export class EventDispatcher extends HashObject {
...
@@ -1285,7 +1285,7 @@ export class EventDispatcher extends HashObject {
* @param context listener和context都相等的才移除,默认自身
* @param context listener和context都相等的才移除,默认自身
* @param {boolean} useCapture true 捕获阶段 false 冒泡阶段 默认 true
* @param {boolean} useCapture true 捕获阶段 false 冒泡阶段 默认 true
*/
*/
removeEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
?:
boolean
):
void
;
removeEventListener
(
type
:
string
,
listener
:
Function
,
context
?:
any
,
useCapture
?:
boolean
):
this
;
/**
/**
* 移除对象中所有的侦听
* 移除对象中所有的侦听
* @method removeAllEventListener
* @method removeAllEventListener
...
@@ -1336,11 +1336,9 @@ export class Point extends HashObject {
...
@@ -1336,11 +1336,9 @@ export class Point extends HashObject {
export
const
VERSION
=
"1.0"
;
export
const
VERSION
=
"1.0"
;
export
const
sysInfo
:
any
;
export
const
devicePixelRatio
:
number
;
export
const
devicePixelRatio
:
number
;
export
const
osType
:
"ios"
|
"android"
;
export
const
osType
:
"ios"
|
"android"
|
"pc"
;
export
function
cos
(
angle
:
number
):
number
;
export
function
cos
(
angle
:
number
):
number
;
...
@@ -2206,9 +2204,9 @@ export function destroyCanvasContent(): void;
...
@@ -2206,9 +2204,9 @@ export function destroyCanvasContent(): void;
export
function
getCreateImage
():
()
=>
HTMLImageElement
;
export
function
getCreateImage
():
()
=>
HTMLImageElement
;
export
function
getRequestAnimationFrame
():
(
fun
:
Function
)
=>
number
;
export
function
getRequestAnimationFrame
():
any
;
export
function
getCancelAnimationFrame
():
(
id
:
any
)
=>
void
;
export
function
getCancelAnimationFrame
():
any
;
export
const
INT_BITS1
=
32
;
export
const
INT_BITS1
=
32
;
...
@@ -4633,6 +4631,13 @@ export class CanvasRenderTarget {
...
@@ -4633,6 +4631,13 @@ export class CanvasRenderTarget {
}
}
export
class
CanvasRenderer
extends
SystemRenderer
{
export
class
CanvasRenderer
extends
SystemRenderer
{
/**
* 主屏幕渲染上下文
*/
rootContext
:
CanvasRenderingContext2D
;
/**
* 当前使用的上下文
*/
context
:
CanvasRenderingContext2D
;
context
:
CanvasRenderingContext2D
;
/**
/**
* 遮罩管理类
* 遮罩管理类
...
@@ -4901,17 +4906,25 @@ export class BaseTexture extends EventDispatcher {
...
@@ -4901,17 +4906,25 @@ export class BaseTexture extends EventDispatcher {
*/
*/
dispose
():
void
;
dispose
():
void
;
/**
/**
*
*
根据路径
* @param {string} url 路径
* @param {string} url 路径
*/
*/
static
fromUrl
(
url
:
string
):
any
;
static
fromUrl
(
url
:
string
):
any
;
static
fromSource
(
source
:
any
):
BaseTexture
;
/**
* 随便啥形式的,比如data,
* @param data
*/
static
fromData
(
data
:
any
):
BaseTexture
;
/**
/**
* 从离屏canvas创建的
* 从离屏canvas创建的
*/
*/
static
fromCanvas
(
canvas
:
HTMLCanvasElement
,
origin
?:
string
):
any
;
static
fromCanvas
(
canvas
:
HTMLCanvasElement
,
origin
?:
string
):
any
;
static
fromImage
(
image
:
HTMLImageElement
):
BaseTexture
;
/**
static
from
(
anyThing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
):
any
;
* 根据图片
* @param image
*/
static
fromImage
(
image
:
HTMLImageElement
):
any
;
static
from
(
anything
:
string
|
HTMLCanvasElement
|
HTMLImageElement
):
any
;
/**
/**
* 加入缓存
* 加入缓存
* @static
* @static
...
@@ -5109,9 +5122,9 @@ export class Texture extends EventDispatcher {
...
@@ -5109,9 +5122,9 @@ export class Texture extends EventDispatcher {
*/
*/
static
fromUrl
(
url
:
string
):
any
;
static
fromUrl
(
url
:
string
):
any
;
static
fromCanvas
(
canvas
:
HTMLCanvasElement
,
origin
?:
string
):
Texture
;
static
fromCanvas
(
canvas
:
HTMLCanvasElement
,
origin
?:
string
):
Texture
;
static
from
Source
(
source
:
any
):
Texture
;
static
from
Data
(
data
:
any
):
Texture
;
static
fromImage
(
image
:
HTMLImageElement
):
Texture
;
static
fromImage
(
image
:
HTMLImageElement
):
Texture
;
static
from
(
any
T
hing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
):
any
;
static
from
(
any
t
hing
:
string
|
HTMLCanvasElement
|
HTMLImageElement
):
any
;
/**
/**
* 加入全局缓存,TextureCache[name]调用
* 加入全局缓存,TextureCache[name]调用
* @static
* @static
...
@@ -5987,14 +6000,14 @@ export class Container extends DisplayObject {
...
@@ -5987,14 +6000,14 @@ export class Container extends DisplayObject {
* @param {DisplayObject} child
* @param {DisplayObject} child
* @return {DisplayObject}
* @return {DisplayObject}
*/
*/
addChild
(
child
:
DisplayObject
):
DisplayObject
;
addChild
<
T
extends
DisplayObject
>
(
child
:
T
):
T
;
/**
/**
* 在相应index处添加child
* 在相应index处添加child
* @param {DisplayObject} child - The child to add
* @param {DisplayObject} child - The child to add
* @param {number} index - The index to place the child in
* @param {number} index - The index to place the child in
* @return {DisplayObject} The child that was added.
* @return {DisplayObject} The child that was added.
*/
*/
addChildAt
(
child
:
DisplayObject
,
index
:
number
):
DisplayObject
;
addChildAt
<
T
extends
DisplayObject
>
(
child
:
T
,
index
:
number
):
T
;
/**
/**
* 只用于交换索引
* 只用于交换索引
* @param {DisplayObject} child - First display object to swap
* @param {DisplayObject} child - First display object to swap
...
@@ -7405,5 +7418,124 @@ export class ShowWord extends TextField {
...
@@ -7405,5 +7418,124 @@ export class ShowWord extends TextField {
* @param callback 播放完后的回调
* @param callback 播放完后的回调
*/
*/
playWords
(
text
:
string
,
deltaTime
?:
number
,
callback
?:
Function
):
void
;
playWords
(
text
:
string
,
deltaTime
?:
number
,
callback
?:
Function
):
void
;
}
export
interface
InnerAudioContext
{
src
:
string
;
startTime
:
number
;
autoplay
:
boolean
;
loop
:
boolean
;
obeyMuteSwitch
:
boolean
;
duration
:
number
;
currentTime
:
number
;
paused
:
boolean
;
buffered
:
number
;
volume
:
number
;
isRecordAudioPlayState
:
boolean
;
play
:
()
=>
void
;
pause
:
()
=>
void
;
stop
:
void
;
seek
:
(
postion
:
number
)
=>
void
;
destroy
:
void
;
onCanplay
:
(
fun
:
()
=>
void
)
=>
void
;
onPlay
:
(
fun
:
()
=>
void
)
=>
void
;
onPause
:
(
fun
:
()
=>
void
)
=>
void
;
onStop
:
(
fun
:
()
=>
void
)
=>
void
;
onEnded
:
(
fun
:
()
=>
void
)
=>
void
;
onTimeUpdate
:
(
fun
:
()
=>
void
)
=>
void
;
onError
:
(
fun
:
()
=>
void
)
=>
void
;
onWaiting
:
(
fun
:
()
=>
void
)
=>
void
;
onSeeking
:
(
fun
:
()
=>
void
)
=>
void
;
onSeeked
:
(
fun
:
()
=>
void
)
=>
void
;
}
export
function
$pushSoundChannel
(
channel
:
SoundChannel
):
void
;
export
function
$popSoundChannel
(
channel
:
SoundChannel
):
boolean
;
export
class
Sound
extends
EventDispatcher
{
/**
* 记录的路径
*/
private
url
;
/**
* 有url了,貌似就没必要了
*/
private
originAudio
;
/**
* @private
*/
private
loaded
;
constructor
();
readonly
length
:
number
;
load
(
url
:
string
):
void
;
/**
* @inheritDoc
*/
play
(
startTime
?:
number
,
loops
?:
number
):
SoundChannel
;
/**
* @inheritDoc
*/
close
():
void
;
/**
* @private
*/
private
static
audios
;
private
static
clearAudios
;
static
$clear
(
url
:
string
):
void
;
static
$pop
(
url
:
string
):
InnerAudioContext
;
static
$recycle
(
url
:
string
,
audio
:
InnerAudioContext
):
void
;
}
export
class
SoundChannel
extends
EventDispatcher
{
/**
* @private
*/
$url
:
string
;
/**
* @private
*/
$loops
:
number
;
/**
* @private
*/
$startTime
:
number
;
/**
* @private
*/
private
audio
;
private
isStopped
;
/**
* @private
*/
constructor
(
audio
:
InnerAudioContext
);
private
canPlay
;
$play
():
void
;
/**
* @private
*/
private
onPlayEnd
;
/**
* @private
* @inheritDoc
*/
stop
():
void
;
/**
* @private
*/
private
_volume
;
/**
* @private
* @inheritDoc
*/
/**
* @inheritDoc
*/
volume
:
number
;
/**
* @private
* @inheritDoc
*/
readonly
position
:
number
;
}}
}}
declare
module
"fyge"
{
export
=
FYGE
;}
declare
module
"fyge"
{
export
=
FYGE
;}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment