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
23e71e8f
Commit
23e71e8f
authored
Aug 06, 2020
by
wjf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
l
parent
c029f17f
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
145 additions
and
47 deletions
+145
-47
FYGE.d.ts
build/FYGE.d.ts
+25
-12
fyge.min.js
build/fyge.min.js
+1
-1
fyge.min.js.map
build/fyge.min.js.map
+1
-1
package.json
package.json
+1
-1
record.txt
record.txt
+38
-1
declare.js
scripts/declare.js
+2
-1
Container.ts
src/2d/display/Container.ts
+2
-1
Sprite.ts
src/2d/display/Sprite.ts
+1
-1
Stage.ts
src/2d/display/Stage.ts
+8
-1
EventDispatcher.ts
src/2d/events/EventDispatcher.ts
+29
-0
CanvasMaskManager.ts
src/2d/renderers/managers/CanvasMaskManager.ts
+2
-1
CanvasGraphicsRenderer.ts
src/2d/renderers/plugins/CanvasGraphicsRenderer.ts
+3
-2
CanvasRenderTarget.ts
src/2d/renderers/renderTarget/CanvasRenderTarget.ts
+2
-1
TextField.ts
src/2d/text/TextField.ts
+5
-1
Button.ts
src/2d/ui/Button.ts
+4
-0
FrameAni.ts
src/2d/ui/FrameAni.ts
+19
-20
MovieClip.ts
src/2d/ui/MovieClip.ts
+1
-1
index.ts
src/2d/utils/index.ts
+1
-1
No files found.
build/FYGE.d.ts
View file @
23e71e8f
...
@@ -493,6 +493,13 @@ export class EventDispatcher extends HashObject {
...
@@ -493,6 +493,13 @@ export class EventDispatcher extends HashObject {
* @return {boolean} 如果有则返回true
* @return {boolean} 如果有则返回true
*/
*/
hasEventListener
(
type
:
string
,
useCapture
?:
boolean
):
boolean
;
hasEventListener
(
type
:
string
,
useCapture
?:
boolean
):
boolean
;
/**
* 清除某一类型的所有事件
* @param type
* @param useCapture true 捕获阶段 false 冒泡阶段 默认 true
* @return 返回自己
*/
removeAllEventListenerByType
(
type
:
string
,
useCapture
?:
boolean
):
this
;
/**
/**
* 移除对应类型的侦听
* 移除对应类型的侦听
* @method removeEventListener
* @method removeEventListener
...
@@ -3638,7 +3645,7 @@ export class Sprite extends Container {
...
@@ -3638,7 +3645,7 @@ export class Sprite extends Container {
texture
:
Texture
;
texture
:
Texture
;
tint
:
number
;
tint
:
number
;
/**
/**
*
*
网络图片
* @param url
* @param url
*/
*/
static
fromUrl
(
url
:
string
):
Sprite
;
static
fromUrl
(
url
:
string
):
Sprite
;
...
@@ -3785,7 +3792,7 @@ export const premultiplyBlendMode: any[];
...
@@ -3785,7 +3792,7 @@ export const premultiplyBlendMode: any[];
export
function
uid
():
number
;
export
function
uid
():
number
;
export
const
backupCanvas
:
HTMLCanvasElement
;
export
function
getBackupCanvasCtx
():
CanvasRenderingContext2D
;
export
function
getGradientColor
(
points
:
any
,
colors
:
any
):
any
;
export
function
getGradientColor
(
points
:
any
,
colors
:
any
):
any
;
...
@@ -6830,10 +6837,17 @@ export class Tween {
...
@@ -6830,10 +6837,17 @@ export class Tween {
}
}
export
class
Button
extends
Sprite
{
export
class
Button
extends
Sprite
{
textureUp
:
any
;
private
textureUp
;
textureDown
:
any
;
private
textureDown
;
textureDisable
:
any
;
private
textureDisable
;
constructor
(
tUp
:
Texture
,
tDown
?:
Texture
,
tDisable
?:
Texture
);
constructor
(
tUp
:
Texture
,
tDown
?:
Texture
,
tDisable
?:
Texture
);
/**
* 修改纹理
* @param tUp
* @param tDown
* @param tDisable
*/
changeTexture
(
tUp
:
Texture
,
tDown
?:
Texture
,
tDisable
?:
Texture
):
void
;
/**
/**
* @method _mouseEvent
* @method _mouseEvent
* @param e
* @param e
...
@@ -6902,7 +6916,7 @@ export class FrameAni extends Container {
...
@@ -6902,7 +6916,7 @@ export class FrameAni extends Container {
*/
*/
constructor
(
texturesAll
:
Texture
[]);
constructor
(
texturesAll
:
Texture
[]);
private
count
;
private
count
;
onEnterFrame
():
void
;
private
onEnterFrame
;
/**
/**
* 从0开始播放
* 从0开始播放
*/
*/
...
@@ -6912,10 +6926,10 @@ export class FrameAni extends Container {
...
@@ -6912,10 +6926,10 @@ export class FrameAni extends Container {
*/
*/
reset
(
frame
?:
number
):
void
;
reset
(
frame
?:
number
):
void
;
/**
/**
*
改texture和居中
*
重置所有贴图,会置0停止,不设置播放,否则原先的play里的startTime及loop不好维护
* @param
index
* @param
texturesAll
*/
*/
private
changeTexture
;
resetTexturesAll
(
texturesAll
:
Texture
[]):
void
;
}
}
export
class
ScrollPage
extends
Container
{
export
class
ScrollPage
extends
Container
{
...
@@ -7270,7 +7284,7 @@ export class MovieClip extends Container {
...
@@ -7270,7 +7284,7 @@ export class MovieClip extends Container {
init
(
mv
:
any
):
void
;
init
(
mv
:
any
):
void
;
private
initChildren
;
private
initChildren
;
/**
/**
* 用基础属性重置
* 用基础属性重置
,废的
* @param display
* @param display
* @param transform
* @param transform
*/
*/
...
@@ -7999,5 +8013,4 @@ export var Stats: (canvasId: any) => {
...
@@ -7999,5 +8013,4 @@ export var Stats: (canvasId: any) => {
update
:
()
=>
void
;
update
:
()
=>
void
;
}
}
export
{
Stats
};}
export
{
Stats
};}
declare
module
"fyge"
{
export
=
FYGE
;}
\ No newline at end of file
\ No newline at end of file
build/fyge.min.js
View file @
23e71e8f
This diff is collapsed.
Click to expand it.
build/fyge.min.js.map
View file @
23e71e8f
This diff is collapsed.
Click to expand it.
package.json
View file @
23e71e8f
{
{
"name"
:
"fyge-tbmini"
,
"name"
:
"fyge-tbmini"
,
"version"
:
"1.
2.5
"
,
"version"
:
"1.
3.2
"
,
"description"
:
"淘宝小程序canvas渲染引擎"
,
"description"
:
"淘宝小程序canvas渲染引擎"
,
"main"
:
"./build/fyge.min.js"
,
"main"
:
"./build/fyge.min.js"
,
"types"
:
"./build/FYGE.d.ts"
,
"types"
:
"./build/FYGE.d.ts"
,
...
...
record.txt
View file @
23e71e8f
...
@@ -24,7 +24,44 @@
...
@@ -24,7 +24,44 @@
1.2.5 shape的点击事件,清除颜色前要先setTransform(1,0,0,1,0,0);
1.2.5 shape的点击事件,清除颜色前要先setTransform(1,0,0,1,0,0);
1.2.6 canvasGraphicsRenderer画洞时的for循环里有bug(j写成了i)
1.2.7 修改canvasGraphicsRenderer的holePath方法里的SHAPES.CIRC,先加moveTo;
canvasRenderTarget 修改,改变canvas宽度resize方法,宽高至少是1;
1.2.8 canvasRenderTarget还原修改,resize,否则可能有bug
1.2.9 button的changeTexture在禁用状态时贴图也要修改
EventDispatcher添加移除指定类型的所有事件removeAllEventListenerByType
1.3.0 canvasMaskManager修改pushMask,置零globalAlpha
frameAni修改,frameRate不判断必执行,否则默写修改过贴图集的会不生效
frameAni新增resetTexturesAll方法
frameAni去掉changeTexture方法,直接整合进currentFrame的set方法
1.3.2 Stage的webgl模式创建webgl上下文时添加属性
textField单行文本检测加入\r \r\n
container里removeChildren在不传参数时的修改
CanvasRenderTarget构造函数里添加clear方法,为了里面的clearRect,(淘宝canvas问题,绘制前必须调用过clearRect,否则有几率画不出来)
//TODO
//TODO
Texture里的removeAllHandlers是否考虑加上tex.removeEventListener = function _emptyOn() { /* empty */ };
Texture里的removeAllHandlers是否考虑加上tex.removeEventListener = function _emptyOn() { /* empty */ };
bitmapText 考虑添加垂直居中方法(还没写),简单起见,没标记过dirty,所以有需要先设置对齐,再设置text
bitmapText 考虑添加垂直居中方法(还没写),简单起见,没标记过dirty,所以有需要先设置对齐,再设置text
graphics的canvas模式渲染,会把子级的也缓存,现在做法,尽量不在矢量图添加子级
graphics的canvas模式渲染,会把子级的也缓存,现在做法,尽量不在矢量图添加子级
\ No newline at end of file
graphics的canvas模式有时候在小程序上画不出来,待检测,主要是rect
shape的beginFill待兼容"#ff0000"和"0xff0000"
ScrollPage在isSpringBack为false也做判断,触发SCROLL_TO_END或SCROLL_TO_HEAD事件
scrollList里不放数据时默认显示了一条(其实n条叠一起),待处理构造函数置空(需测试)
shape作为遮罩时并未计算过_localBoundSelf,导致遮罩加遮罩物的点击有问题,后续考虑分开计算_localBoundSelf,暂时手动执行updateShape()
svga的纹理考虑单独缓存在自己的数据里,不进TextureCache,movieClip的textures注意拷贝svga上的数据
多page上的canvas,存在资源干扰的情况,考虑RES单独缓存,不进TextureCache缓存,createTextureSheet也不缓存进TextureCache
淘宝小程序的canvas路径api没用非零环绕原则,必须逆时针绘制想绘制的,顺时针绘制镂空的
文本在fillText没修复前,空格用\t替代
\ No newline at end of file
scripts/declare.js
View file @
23e71e8f
...
@@ -40,7 +40,8 @@ function compile(fileNames, options) {
...
@@ -40,7 +40,8 @@ function compile(fileNames, options) {
;
;
// const content = `declare module FYGE{${allExports}}`;
// const content = `declare module FYGE{${allExports}}`;
const
content
=
`declare namespace FYGE{
${
allExports
}
}\ndeclare module "fyge" {export = FYGE;}`
;
// const content = `declare namespace FYGE{${allExports}}\ndeclare module "fyge" {export = FYGE;}`;
const
content
=
`declare namespace FYGE{
${
allExports
}
}`
;
//不作为npm使用时还是去掉吧
fs
.
writeFileSync
(
'build/FYGE.d.ts'
,
content
);
fs
.
writeFileSync
(
'build/FYGE.d.ts'
,
content
);
}
}
...
...
src/2d/display/Container.ts
View file @
23e71e8f
...
@@ -265,7 +265,8 @@ export default class Container extends DisplayObject {
...
@@ -265,7 +265,8 @@ export default class Container extends DisplayObject {
* @param children 不传参数,表示全部移除
* @param children 不传参数,表示全部移除
*/
*/
removeChildren
<
T
extends
DisplayObject
>
(...
children
:
T
[]):
T
[]
{
removeChildren
<
T
extends
DisplayObject
>
(...
children
:
T
[]):
T
[]
{
if
(
!
children
.
length
)
return
this
.
spliceChildren
(
0
);
//待测试,arr.splice(0)会全部删除,arr.splice(0,undefined)不会,所以this.spliceChildren(0)下面执行的是splice(0,undefined)
if
(
!
children
.
length
)
return
this
.
spliceChildren
(
0
,
this
.
children
.
length
);
children
.
forEach
((
child
:
T
)
=>
{
this
.
removeChild
(
child
);
})
children
.
forEach
((
child
:
T
)
=>
{
this
.
removeChild
(
child
);
})
return
children
return
children
...
...
src/2d/display/Sprite.ts
View file @
23e71e8f
...
@@ -503,7 +503,7 @@ export default class Sprite extends Container {
...
@@ -503,7 +503,7 @@ export default class Sprite extends Container {
//一些静态类方法
//一些静态类方法
/**
/**
*
*
网络图片
* @param url
* @param url
*/
*/
static
fromUrl
(
url
:
string
):
Sprite
{
static
fromUrl
(
url
:
string
):
Sprite
{
...
...
src/2d/display/Stage.ts
View file @
23e71e8f
...
@@ -165,7 +165,14 @@ export class Stage extends Container {
...
@@ -165,7 +165,14 @@ export class Stage extends Container {
let
context
=
canvas
.
getContext
(
"2d"
);
let
context
=
canvas
.
getContext
(
"2d"
);
s
.
renderObj
=
new
CanvasRenderer
(
context
,
canvas
.
width
,
canvas
.
height
);
s
.
renderObj
=
new
CanvasRenderer
(
context
,
canvas
.
width
,
canvas
.
height
);
}
else
{
}
else
{
let
context
=
canvas
.
getContext
(
"webgl"
);
let
context
=
canvas
.
getContext
(
"webgl"
,
{
alpha
:
true
,
antialias
:
false
,
//抗锯齿尽量别开,耗性能
premultipliedAlpha
:
true
,
//一般png图片都不会预乘alpha,所以必为true,除非有些图集工具选择了premultipliedAlpha
stencil
:
true
,
// preserveDrawingBuffer: this.options.preserveDrawingBuffer,//需要toDataUrl时要开
// powerPreference: this.options.powerPreference,
});
s
.
renderObj
=
new
WebglRenderer
(
context
,
canvas
.
width
,
canvas
.
height
);
s
.
renderObj
=
new
WebglRenderer
(
context
,
canvas
.
width
,
canvas
.
height
);
}
}
...
...
src/2d/events/EventDispatcher.ts
View file @
23e71e8f
...
@@ -246,6 +246,35 @@ export class EventDispatcher extends HashObject {
...
@@ -246,6 +246,35 @@ export class EventDispatcher extends HashObject {
}
}
return
false
;
return
false
;
}
}
/**
* 清除某一类型的所有事件
* @param type
* @param useCapture true 捕获阶段 false 冒泡阶段 默认 true
* @return 返回自己
*/
public
removeAllEventListenerByType
(
type
:
string
,
useCapture
:
boolean
=
true
):
this
{
let
s
=
this
;
if
(
useCapture
)
{
if
(
s
.
eventTypes
[
type
]
&&
s
.
eventTypes
[
type
].
length
>
0
)
{
if
(
type
.
indexOf
(
"onMouse"
)
==
0
)
{
for
(
let
j
=
0
;
j
<
s
.
eventTypes
[
type
].
length
;
j
++
)
{
s
.
_changeMouseCount
(
type
,
false
);
}
}
s
.
eventTypes
[
type
]
=
[];
}
}
else
{
if
(
s
.
eventTypes1
[
type
]
&&
s
.
eventTypes1
[
type
].
length
>
0
)
{
if
(
type
.
indexOf
(
"onMouse"
)
==
0
)
{
for
(
let
j
=
0
;
j
<
s
.
eventTypes1
[
type
].
length
;
j
++
)
{
s
.
_changeMouseCount
(
type
,
false
);
}
}
s
.
eventTypes1
[
type
]
=
[];
}
}
return
s
}
/**
/**
* 移除对应类型的侦听
* 移除对应类型的侦听
...
...
src/2d/renderers/managers/CanvasMaskManager.ts
View file @
23e71e8f
import
{
SHAPES
}
from
'../../const'
;
import
{
SHAPES
}
from
'../../const'
;
import
{
HashObject
}
from
'../../HashObject'
;
import
{
HashObject
}
from
'../../HashObject'
;
import
{
CanvasRenderer
}
from
'../CanvasRenderer'
;
import
{
CanvasRenderer
}
from
'../CanvasRenderer'
;
import
Graphics
from
'../../graphics/Graphics'
;
import
Graphics
from
'../../graphics/Graphics'
;
import
GraphicsData
from
'../../graphics/GraphicsData'
;
import
GraphicsData
from
'../../graphics/GraphicsData'
;
import
{
holePath
,
judgeCcw
}
from
'../plugins/CanvasGraphicsRenderer'
;
import
{
holePath
,
judgeCcw
}
from
'../plugins/CanvasGraphicsRenderer'
;
...
@@ -27,6 +27,7 @@ export default class CanvasMaskManager extends HashObject {
...
@@ -27,6 +27,7 @@ export default class CanvasMaskManager extends HashObject {
pushMask
(
maskData
:
Graphics
)
{
pushMask
(
maskData
:
Graphics
)
{
const
renderer
=
this
.
renderer
;
const
renderer
=
this
.
renderer
;
renderer
.
context
.
save
();
renderer
.
context
.
save
();
renderer
.
context
.
globalAlpha
=
0
;
//得加上,不绘制
const
transform
=
maskData
.
transform
.
worldMatrix
;
const
transform
=
maskData
.
transform
.
worldMatrix
;
renderer
.
context
.
setTransform
(
renderer
.
context
.
setTransform
(
transform
.
a
,
transform
.
a
,
...
...
src/2d/renderers/plugins/CanvasGraphicsRenderer.ts
View file @
23e71e8f
import
{
CanvasRenderer
}
from
'../CanvasRenderer'
;
import
{
CanvasRenderer
}
from
'../CanvasRenderer'
;
import
{
SHAPES
}
from
'../../const'
;
import
{
SHAPES
}
from
'../../const'
;
import
Graphics
from
'../../graphics/Graphics'
;
import
Graphics
from
'../../graphics/Graphics'
;
import
GraphicsData
from
'../../graphics/GraphicsData'
;
import
GraphicsData
from
'../../graphics/GraphicsData'
;
...
@@ -143,7 +143,7 @@ export class CanvasGraphicsRenderer {
...
@@ -143,7 +143,7 @@ export class CanvasGraphicsRenderer {
//有洞的话,洞的路径需反向,必须闭合,上面一般图形都是顺时针
//有洞的话,洞的路径需反向,必须闭合,上面一般图形都是顺时针
for
(
let
j
=
0
;
j
<
data
.
holes
.
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
data
.
holes
.
length
;
j
++
)
{
holePath
(
data
.
holes
[
i
],
context
,
ccw
)
holePath
(
data
.
holes
[
j
],
context
,
ccw
)
}
}
if
(
fillStyle
.
visible
)
{
if
(
fillStyle
.
visible
)
{
...
@@ -220,6 +220,7 @@ export function holePath(graphicsData: GraphicsData, context: CanvasRenderingCon
...
@@ -220,6 +220,7 @@ export function holePath(graphicsData: GraphicsData, context: CanvasRenderingCon
}
}
break
;
break
;
case
SHAPES
.
CIRC
:
case
SHAPES
.
CIRC
:
context
.
moveTo
(
shape
.
x
+
shape
.
radius
,
shape
.
y
);
//得先加这个
context
.
arc
(
shape
.
x
,
shape
.
y
,
shape
.
radius
,
0
,
2
*
Math
.
PI
,
ccw
);
context
.
arc
(
shape
.
x
,
shape
.
y
,
shape
.
radius
,
0
,
2
*
Math
.
PI
,
ccw
);
break
;
break
;
case
SHAPES
.
ELIP
:
case
SHAPES
.
ELIP
:
...
...
src/2d/renderers/renderTarget/CanvasRenderTarget.ts
View file @
23e71e8f
...
@@ -27,7 +27,8 @@ export default class CanvasRenderTarget {
...
@@ -27,7 +27,8 @@ export default class CanvasRenderTarget {
this
.
resize
(
width
,
height
);
//要先设置尺寸?
this
.
resize
(
width
,
height
);
//要先设置尺寸?
this
.
context
=
this
.
canvas
.
getContext
(
'2d'
);
this
.
context
=
this
.
canvas
.
getContext
(
'2d'
);
// console.log("rd",this.context)
// console.log("rd",this.context)
this
.
resize
(
width
,
height
);
this
.
resize
(
width
,
height
);
//为何要多加一次
this
.
clear
();
//淘宝canvas问题,绘制前必须调用过clearRect,否则就有几率绘制不出来
}
}
/**
/**
...
...
src/2d/text/TextField.ts
View file @
23e71e8f
...
@@ -516,7 +516,11 @@ export class TextField extends Sprite {
...
@@ -516,7 +516,11 @@ export class TextField extends Sprite {
let
textWidth
=
s
.
_textWidth
;
let
textWidth
=
s
.
_textWidth
;
// let lineH = s._lineSpacing + s.size;
// let lineH = s._lineSpacing + s.size;
//单行文本时
//单行文本时
if
(
s
.
_text
.
indexOf
(
"
\n
"
)
<
0
&&
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
)
{
if
(
s
.
_text
.
indexOf
(
"
\n
"
)
<
0
&&
//没有换行符
s
.
_text
.
indexOf
(
"
\
r"
)
<
0
&&
//没有换行符
s
.
_text
.
indexOf
(
"
\
r
\n
"
)
<
0
&&
//没有换行符
s
.
lineType
==
TEXT_lINETYPE
.
SINGLE
//确定单行
)
{
realLines
[
realLines
.
length
]
=
hardLines
[
0
];
realLines
[
realLines
.
length
]
=
hardLines
[
0
];
let
str
=
hardLines
[
0
];
let
str
=
hardLines
[
0
];
let
lineW
=
s
.
_getMeasuredWidth
(
str
);
let
lineW
=
s
.
_getMeasuredWidth
(
str
);
...
...
src/2d/ui/Button.ts
View file @
23e71e8f
...
@@ -37,6 +37,10 @@ export class Button extends Sprite {
...
@@ -37,6 +37,10 @@ export class Button extends Sprite {
//如果是点击状态时且有down
//如果是点击状态时且有down
if
(
this
.
_clicked
&&
this
.
textureDown
)
{
if
(
this
.
_clicked
&&
this
.
textureDown
)
{
this
.
texture
=
this
.
textureDown
;
this
.
texture
=
this
.
textureDown
;
}
//禁用状态时
else
if
(
!
this
.
mouseEnable
&&
!
this
.
textureStatusEnable
)
{
this
.
texture
=
this
.
textureDisable
;
}
else
{
}
else
{
this
.
texture
=
this
.
textureUp
;
this
.
texture
=
this
.
textureUp
;
}
}
...
...
src/2d/ui/FrameAni.ts
View file @
23e71e8f
...
@@ -19,7 +19,15 @@ export class FrameAni extends Container {
...
@@ -19,7 +19,15 @@ export class FrameAni extends Container {
* 从0开始 锁步会跳帧
* 从0开始 锁步会跳帧
* 每一帧就是一张图片,从0开始
* 每一帧就是一张图片,从0开始
*/
*/
private
currentFrame
:
number
;
// private _currentFrame: number;//暂时只有不锁步时才需要,但是已经注释,需要时加get方法
private
set
currentFrame
(
value
:
number
)
{
if
(
this
.
texturesAll
[
value
])
{
this
.
showImage
.
texture
=
this
.
texturesAll
[
value
];
}
else
{
this
.
showImage
.
texture
=
null
;
}
}
/**
/**
* 所有帧数
* 所有帧数
*/
*/
...
@@ -54,7 +62,7 @@ export class FrameAni extends Container {
...
@@ -54,7 +62,7 @@ export class FrameAni extends Container {
return
this
.
_frameRate
return
this
.
_frameRate
}
}
set
frameRate
(
value
:
number
)
{
set
frameRate
(
value
:
number
)
{
if
(
value
==
this
.
_frameRate
)
return
// if (value == this._frameRate) return//注释掉吧,否则frameRate修改相同,但是texturesAll变了就执行不到了
this
.
_frameRate
=
value
;
this
.
_frameRate
=
value
;
this
.
allTime
=
this
.
texturesAll
.
length
/
this
.
_frameRate
*
1000
;
this
.
allTime
=
this
.
texturesAll
.
length
/
this
.
_frameRate
*
1000
;
}
}
...
@@ -68,14 +76,13 @@ export class FrameAni extends Container {
...
@@ -68,14 +76,13 @@ export class FrameAni extends Container {
this
.
showImage
.
anchorTexture
.
set
(
0.5
,
0.5
);
this
.
showImage
.
anchorTexture
.
set
(
0.5
,
0.5
);
this
.
addChild
(
this
.
showImage
);
this
.
addChild
(
this
.
showImage
);
this
.
texturesAll
=
texturesAll
;
this
.
texturesAll
=
texturesAll
;
this
.
changeTexture
(
0
);
this
.
currentFrame
=
0
;
this
.
currentFrame
=
0
;
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)
this
.
addEventListener
(
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)
this
.
frameRate
=
30
;
this
.
frameRate
=
30
;
}
}
//需要做锁步
//需要做锁步
private
count
=
0
;
private
count
=
0
;
onEnterFrame
()
{
private
onEnterFrame
()
{
if
(
!
this
.
isPlay
)
{
if
(
!
this
.
isPlay
)
{
// this.count = 0
// this.count = 0
return
return
...
@@ -103,11 +110,9 @@ export class FrameAni extends Container {
...
@@ -103,11 +110,9 @@ export class FrameAni extends Container {
}
else
{
}
else
{
this
.
startTime
=
Date
.
now
()
this
.
startTime
=
Date
.
now
()
this
.
currentFrame
=
0
;
this
.
currentFrame
=
0
;
this
.
changeTexture
(
this
.
currentFrame
);
}
}
}
else
{
}
else
{
this
.
currentFrame
=
(
scale
*
this
.
texturesAll
.
length
)
>>
0
;
this
.
currentFrame
=
(
scale
*
this
.
texturesAll
.
length
)
>>
0
;
this
.
changeTexture
(
this
.
currentFrame
);
}
}
}
}
/**
/**
...
@@ -117,7 +122,6 @@ export class FrameAni extends Container {
...
@@ -117,7 +122,6 @@ export class FrameAni extends Container {
this
.
startTime
=
Date
.
now
();
this
.
startTime
=
Date
.
now
();
this
.
isPlay
=
true
;
this
.
isPlay
=
true
;
this
.
currentFrame
=
0
;
this
.
currentFrame
=
0
;
this
.
changeTexture
(
0
);
this
.
loop
=
loop
;
this
.
loop
=
loop
;
this
.
callback
=
callback
;
this
.
callback
=
callback
;
}
}
...
@@ -127,21 +131,16 @@ export class FrameAni extends Container {
...
@@ -127,21 +131,16 @@ export class FrameAni extends Container {
reset
(
frame
:
number
=
0
)
{
reset
(
frame
:
number
=
0
)
{
this
.
isPlay
=
false
;
this
.
isPlay
=
false
;
this
.
currentFrame
=
frame
;
this
.
currentFrame
=
frame
;
this
.
changeTexture
(
frame
);
}
}
/**
/**
*
改texture和居中
*
重置所有贴图,会置0停止,不设置播放,否则原先的play里的startTime及loop不好维护
* @param
index
* @param
texturesAll
*/
*/
private
changeTexture
(
index
:
number
)
{
resetTexturesAll
(
texturesAll
:
Texture
[])
{
//考虑空帧的情况
this
.
texturesAll
=
texturesAll
;
if
(
this
.
texturesAll
[
index
])
{
this
.
currentFrame
=
0
;
this
.
showImage
.
texture
=
this
.
texturesAll
[
index
];
this
.
frameRate
=
30
;
// this.showImage.x = -this.texturesAll[index].width / 2;
// this.showImage.y = -this.texturesAll[index].height / 2;
}
else
{
this
.
showImage
.
texture
=
null
;
}
}
}
}
}
\ No newline at end of file
src/2d/ui/MovieClip.ts
View file @
23e71e8f
...
@@ -260,7 +260,7 @@ export class MovieClip extends Container {
...
@@ -260,7 +260,7 @@ export class MovieClip extends Container {
}
}
/**
/**
* 用基础属性重置
* 用基础属性重置
,废的
* @param display
* @param display
* @param transform
* @param transform
*/
*/
...
...
src/2d/utils/index.ts
View file @
23e71e8f
...
@@ -111,7 +111,7 @@ export function string2hex(string: string) {
...
@@ -111,7 +111,7 @@ export function string2hex(string: string) {
if
(
string
.
indexOf
(
"#"
)
==
0
)
{
if
(
string
.
indexOf
(
"#"
)
==
0
)
{
string
=
string
.
replace
(
"#"
,
"0x"
)
string
=
string
.
replace
(
"#"
,
"0x"
)
}
}
return
parseInt
(
string
)
return
parseInt
(
string
)
//到时改成+号
}
}
/**
/**
...
...
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