Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
SuCicada committed Nov 15, 2019
1 parent 75aa722 commit 7907a7e
Show file tree
Hide file tree
Showing 18 changed files with 14,924 additions and 0 deletions.
1,201 changes: 1,201 additions & 0 deletions docs/api/APG.Assets.html

Large diffs are not rendered by default.

1,997 changes: 1,997 additions & 0 deletions docs/api/APG.Bag.html

Large diffs are not rendered by default.

1,432 changes: 1,432 additions & 0 deletions docs/api/APG.Game.html

Large diffs are not rendered by default.

1,026 changes: 1,026 additions & 0 deletions docs/api/APG.Group.html

Large diffs are not rendered by default.

2,210 changes: 2,210 additions & 0 deletions docs/api/APG.Sprite.html

Large diffs are not rendered by default.

1,182 changes: 1,182 additions & 0 deletions docs/api/APG.Target.html

Large diffs are not rendered by default.

1,810 changes: 1,810 additions & 0 deletions docs/api/APG.Update.collision.html

Large diffs are not rendered by default.

1,251 changes: 1,251 additions & 0 deletions docs/api/APG.Update.listenKey.html

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions docs/api/Assets.js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
<!DOCTYPE html>


<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Algorithm PlayGround Source: Assets.js</title>
<link rel="stylesheet" href="styles/site.phaser.css?">
</head>

<body>


<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">Algorithm PlayGround</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">

<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="APG.Assets.html">APG.Assets</a></li><li><a href="APG.Bag.html">APG.Bag</a></li><li><a href="APG.Game.html">APG.Game</a></li><li><a href="APG.Group.html">APG.Group</a></li><li><a href="APG.Sprite.html">APG.Sprite</a></li><li><a href="APG.Target.html">APG.Target</a></li><li><a href="APG.Update.listenKey.html">APG.Update.listenKey</a></li><li><a href="APG.Update.collision.html">APG.Update.collision</a></li>
</ul>
</li>

<li>
<a href="https://github.com/SuCicada/Algorithm-PlayGround">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
GitHub
</a>
</li>

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-globe" aria-hidden="true"></span>
Community
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a href="http:../">APG</a>
</li>
<li>
<a href="https://github.com/SuCicada/Algorithm-PlayGround">APG on GitHub</a>
</li>
<li>
<a href="http:../../Examples">APG Examples</a>
</li>
<li>
<a href="">Forum</a>
</li>
<li>
<a href="">Twitter</a>
</li>
<li>
<a href="">Donate</a>
</li>
</ul>
</li>

</ul>

</div>
</div>
</div>


<div class="container-fluid" id="toc-content">
<div class="row">

<div class="col-md-12">

<div id="main">

<h1 class="page-title">Source: Assets.js</h1>

<section>
<article>
<pre class="language-javascript linenums">console.log("Assets.js has been loaded successfully.")
/* ========== Assets ==================== */
/**
* Assets(资源):游戏需要加载的资源,也是接口的一个分类。
* @class APG.Assets
*/
APG.Assets;
APG.Assets.virtualButton;

/**
* 播放音乐
* @method APG.Assets#playMusic
* @param {string} keyName - 音乐名
*/
APG.Assets.playMusic = function (keyName) {
APG.Assets.music[keyName].play('', 0, 1, true);
console.log("Play music: " + keyName);
};

/**
* 停止音乐。如果没有传入名称,则全部停止
* @method APG.Assets#stopMusic
* @param {string} keyName - 音乐名
*/
APG.Assets.stopMusic = function(keyName){
let musics = keyName? {keyName:APG.Assets.music[keyName]}: APG.Assets.music;
for(m in musics){
APG.Assets.music[m].stop();
console.log("Stop music: "+keyName);
}
};

/**
* 添加动画, 并播放.
* @method APG.Assets#setAnimations
* @param {Phaser.Group|Phaser.Sprite} obj - 要设置的对象
* @param {string} name - 动作名
* @param {Array} frames - 帧id
* @param {integer} [frameRate = 1] - 帧动画速度
* @param {boolean} [loop = false] - 循环否
*/
APG.Assets.setAnimations = function(obj, name, frames, frameRate=1, loop=false){
/*
* */
if(typeof frames == "number"){
frames = [frames]
}
if(!obj.forEach){
let s = obj;
if(frames){
}
if(!s.animations.getAnimation(name)){
s.animations.add(name,frames);
}
s.animations.play(name, frameRate, loop);
}else{
let group = obj;
group.forEach(function(s){
if(!s.animations.getAnimation(name)) {
s.animations.add(name, frames);
}
s.animations.play(name, frameRate, loop);
});
}
};

/**
* 设置玩家移动动画
* @method APG.Assets#playerMoveAnimations
* @param {Phaser.Group|Phaser.Sprite} playerG - 玩家对象
* @param {object} obj - 方向(大写,或小写 -> frames 或单个数字,比如
* {
* right: 0,
* LEFT: [1],
* d own: [2],
* up: 3,
* }
*/
APG.Assets.playerMoveAnimations = function(playerG, obj){
var move = {};
for(var i in obj){
var I = i.toUpperCase()
move[I] = typeof obj[i] == 'number'?[obj[i]]: obj[i];

}
if(playerG.animations){
playerG.animations.add(I, move[I], 1);
playerG.Assets.move = move;
}else{
playerG.forEach(function(s){
s.animations.add(I, move[I], 1);
s.Assets = {};
s.Assets.move = move;
});
playerG.Assets = {};
playerG.Assets.move = move;
}
};

/**
* 根据传入的精灵或组,返回此精灵当前的动画的frameId
* @method APG.Assets#getFrame
* @param {Phaser.Group|Phaser.Sprite} obj - 精灵或组或精灵列表
* @returns {Array|number} 如果传入组或精灵列表,返回frameId 列表
*/
APG.Assets.getFrame = function(obj){
if(obj.animations){
/* sprite */
return obj.animations.frame;
}else{
/* group or sprite List*/
var frames = [];
obj.forEach(function(s){
frames.push(s.animations.frame);
});
return frames;
}

};


APG.Assets.setVirtualButton = function(name, x, y, func){
// APG.Assets.virtualButton["button"] = button;
APG.Assets.virtualButton.push({
"name": name,
"x": x,
"y": y,
"func": func,
"buttonObj": null, // 会由APG-core进行赋值
})
};

APG.Assets.deleteVirtualButton = function(name){
for(i = 0;i&lt;APG.Assets.virtualButton.length;i++) {
if (APG.Assets.virtualButton[i].name = name) {
var obj = APG.Assets.virtualButton[i].buttonObj;
if (obj) {
obj.destroy()
}
APG.Assets.virtualButton.pop(i)
break;
}
}
}

APG.Assets.changeVirtualButton = function(name,newName){
var bnt = APG.Assets.virtualButton.find(function(b){
return b.name==name;
})
if(bnt &amp;&amp; game.cache.checkImageKey(newName)){
bnt.name = newName;
bnt.buttonObj.loadTexture(newName)
}
}</pre>
</article>
</section>




</div>
<footer class="footer">




<p class="footer-message">
啊啊啊啊啊
</p>



<p class="copyright">
APG Copyright © ....
</p>


<p class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a>

on 2019-11-Fr

using <a href="https://github.com/photonstorm/phaser-ce/tree/master/resources/docstrap-master">Tomorrow</a>.
</p>

</footer>

</div>

</div>
</div>

<script defer src="scripts/bundle.js?"></script>



</body>
</html>
Loading

0 comments on commit 7907a7e

Please sign in to comment.