new Tiny.Application(conf)
| Name | Type | Description |
|---|---|---|
conf |
Tiny.config |
启动参数 |
Example
// 定义启动参数
var config = {
showFPS: true,
renderOptions: {
backgroundColor: 0x2a3145
}
};
// 新建App
var app = new Tiny.Application(config);
// 通过 fromImage 实例化精灵
var sprite = Tiny.Sprite.fromImage('https://zos.alipayobjects.com/rmsportal/nJBojwdMJfUqpCWvwyoA.png');
// 启动
app.run(sprite);
Members
-
staticTiny.Application.FPSnumber
-
设置或获取已设置的帧率
- Version:
- 1.1.7
-
cameraTiny.Container
-
所有显示类的根容器
-
WebGL renderer if available, otherwise CanvasRenderer
Example
var renderer = app.renderer -
stageTiny.Container
-
舞台对象,用户创建的显示类都会添加到这个对象中
-
tickerTiny.ticker.Ticker
-
Ticker for doing render updates.
-
viewHTMLCanvasElement
-
就是那个用于渲染故事的普通
<canvas>画布对象Properties:
Name Type Description view
Methods
-
destroy(removeView, stageOptions)
-
Destroy and don't use after this.
Name Type Default Description removeViewboolean false optional Automatically remove canvas from DOM.
stageOptionsobject | boolean optional Options parameter. A boolean will act as if all options have been set to that value
Name Type Default Description childrenboolean false optional if set to true, all the children will have their destroy method called as well. 'stageOptions' will be passed on to those calls.
textureboolean false optional Only used for child Sprites if stageOptions.children is set to true. Should it destroy the texture of the child sprite
baseTextureboolean false optional Only used for child Sprites if stageOptions.children is set to true. Should it destroy the base texture of the child sprite
-
getCurrentFPS() ❯ {number}
-
获取当前帧率
- Version:
- 1.1.7
Returns:
Type Description number -
getCurrentScene() ❯ {Tiny.DisplayObject}
-
获取当前场景
- Version:
- 1.1.7
Returns:
Type Description Tiny.DisplayObject -
isPaused() ❯ {boolean}
-
是否暂停中
Returns:
Type Description boolean -
offUpdate(fn)
-
移除主调度中的某个方法
Name Type Description fn- Version:
- 1.0.2
Example
var app = new Tiny.Application(); var fn = function() { console.log('update.'); } app.onUpdate(fn); // 5秒后移除fn Tiny.ticker.shared.countDown({ duration: 1e3, times: 5, complete: function () { app.offUpdate(fn); } }); -
onUpdate(fn, force)
-
游戏的主调度
Name Type Default Description fnfunction forceboolean false optional 是否强制覆盖方法池中同一个方法
Example
var app = new Tiny.Application(); var fn = function() { console.log('update.'); } app.onUpdate(fn); -
pause()
-
暂停
- 暂停
Tiny.ticker.shared下的所有事件(含主调度) - 暂停
Tiny.TWEEN动画 - 暂停
CountDown实例 - 暂停
tinyjs-plugin-audio的 Audio 实例
- 暂停
-
render()
-
Render the current camera.
-
replaceScene(scene, transition, duration)
-
切换场景,如果你想切换下一个场景,使用 replaceScene,还可以使用转场动画
Name Type Description sceneTiny.DisplayObject 场景对象
transitionstring optional 转场动画的字符,比如:Fade、MoveIn等。更多参照 Tiny.Transition
durationnumber optional 转场动画时长(单位:ms)
Example
var app = new Tiny.Application({..}); app.replaceScene(scene, 'SlideInR', 800); -
resume()
-
恢复
- 恢复暂停的
Tiny.ticker.shared下的所有事件(含主调度) - 恢复暂停的
Tiny.TWEEN动画 - 恢复暂停的
CountDown实例 - 恢复暂停的
tinyjs-plugin-audio的 Audio 实例
- 恢复暂停的
-
run(startScene)
-
启动某个场景
Name Type Description startSceneTiny.DisplayObject -
start()
-
开始
-
stop()
-
停止
注意:该方法已不推荐使用,请直接使用pause方法- Deprecated
- since version 1.1.7