Class: Application

Tiny. Application

故事从这里开始

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

所有显示类的根容器

WebGL renderer if available, otherwise CanvasRenderer

Example
var renderer = app.renderer

舞台对象,用户创建的显示类都会添加到这个对象中

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
removeView boolean false optional

Automatically remove canvas from DOM.

stageOptions object | boolean optional

Options parameter. A boolean will act as if all options have been set to that value

Name Type Default Description
children boolean 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.

texture boolean false optional

Only used for child Sprites if stageOptions.children is set to true. Should it destroy the texture of the child sprite

baseTexture boolean 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

获取当前场景

Version:
  • 1.1.7
Returns:
Type Description
Tiny.DisplayObject

isPaused(){boolean}

是否暂停中

Returns:
Type Description
boolean

移除主调度中的某个方法

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
fn function
force boolean false optional

是否强制覆盖方法池中同一个方法

Example
var app = new Tiny.Application();
var fn = function() {
 console.log('update.');
}

app.onUpdate(fn);

暂停

  • 暂停 Tiny.ticker.shared 下的所有事件(含主调度)
  • 暂停 Tiny.TWEEN 动画
  • 暂停 CountDown 实例
  • 暂停 tinyjs-plugin-audio 的 Audio 实例

Render the current camera.

replaceScene(scene, transition, duration)

切换场景,如果你想切换下一个场景,使用 replaceScene,还可以使用转场动画

Name Type Description
scene Tiny.DisplayObject

场景对象

transition string optional

转场动画的字符,比如:Fade、MoveIn等。更多参照 Tiny.Transition

duration number optional

转场动画时长(单位:ms)

Example
var app = new Tiny.Application({..});
app.replaceScene(scene, 'SlideInR', 800);

恢复

  • 恢复暂停的 Tiny.ticker.shared 下的所有事件(含主调度)
  • 恢复暂停的 Tiny.TWEEN 动画
  • 恢复暂停的 CountDown 实例
  • 恢复暂停的 tinyjs-plugin-audio 的 Audio 实例

启动某个场景

Name Type Description
startScene Tiny.DisplayObject

开始

停止
注意:该方法已不推荐使用,请直接使用 pause 方法

Deprecated
  • since version 1.1.7
    Documentation generated by JSDoc 3.4.3 on Fri Jul 09 2021 19:32:26 GMT+0800 (CST)