API Docs for: 1.10.1 最后更新日期:2016年03月28日
Google搜索   
Show:

全局函数 Class

Defined in: utils/Function.js:1

Available since 1.0.0

Methods

addChild

(
  • child
)
public

Defined in utils/Function.js:248

Available since 1.0.0

将一个 DisplayObject 子实例添加到Stage。

Parameters:

Example:

var backLayer = LSprite();
addChild(backLayer);

base

() public

Defined in utils/Function.js:346

Available since 1.0.0

等同于 LExtends

getTimer

() Float public

Defined in utils/Function.js:405

Available since 1.0.0

返回自引擎初始化开始播放时起已经过的毫秒数。

Returns:

Float:

自引擎初始化开始播放时起已经过的毫秒数。

LExtends

(
  • child
  • parent
  • params
)
public

Defined in utils/Function.js:375

Available since 1.0.0

对象继承。等同于 base。

Parameters:

  • child Object

    子对象本身。

  • parent Object

    父对象。

  • params Array

    参数。

Example:

LInit(50, "legend", 800, 480, main);
function FatherClass(){
    this.name = "Father";
}
FatherClass.prototype.getName = function(){
    return this.name;
};
function ChildClass(){
    LExtends(this,FatherClass,[]);
    this.name = "Child";
}
function main () {
    LGlobal.setDebug(true);
    var father = new FatherClass();
    var child = new ChildClass();
    trace("father.getName() = " + father.getName()); //father.getName() = Father
    trace("child.getName() = " + child.getName());//child.getName() = Child
}

LInit

(
  • speed
  • divid
  • width
  • height
  • callback
  • type
)
public

Defined in utils/Function.js:275

Available since 1.0.0

引擎初始化函数。等同于 init。

Parameters:

  • speed Float

    游戏速度,每次页面刷新间隔(单位毫秒), FPS = 1000 / speed。

    *也可以直接将此参数设定为requestAnimationFrame,引擎会切换到requestAnimationFrame来循环刷新。

  • divid String

    传入一个div的id,库件进行初始化的时候,会自动将canvas加入到此div内部。

  • width Int

    游戏界面宽。

  • height Int

    游戏界面高。

  • callback Function

    游戏初始化后,调用此函数。

  • type String

    *该参数在1.10.1之后已被删除,改为引擎内部自动判定。

    当为null时,会先进行页面的onload操作,如果你的init函数调用是在onload之后,那么需要将此参数设为LEvent.INIT。

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>demo</title>
</head>
<body>
<div id="mylegend">loading……</div>
<script type="text/javascript" src="../lufylegend-x.x.x.min.js"></script> 
<script>
LInit(50,"mylegend",800,480,main);
//window.onload = function(){LInit(50, "mylegend", 800, 480, main, LEvent.INIT);};
function main(){
    alert("Hello lufylegend!");
}
</script>
</body>
</html>

removeChild

(
  • child
)
public

Defined in utils/Function.js:261

Available since 1.0.0

从 Stage 实例的子列表中删除指定的 child DisplayObject 实例。

Parameters:

Example:

var backLayer = LSprite();
addChild(backLayer);
removeChild(backLayer);

trace

(
  • expression
)
public

Defined in utils/Function.js:182

Available since 1.0.0

您可以在测试环境下捕获来自 trace() 函数的输出并显示结果。如果 trace 语句中的任何参数包含 String 之外的数据类型,则 trace 函数将调用与该数据类型关联的 toString() 方法。例如,如果该参数是一个布尔值,则跟踪函数将调用 Boolean.toString() 并显示返回值。

Parameters:

  • expression Object

    要计算的表达式。expression 参数的值显示在"输出"面板中。

Example:

trace("debug text 1", "debug text 2", "debug text 3");