'+text);
26 | document.getElementById('log-con').innerHTML+=text+'
';
27 | }
28 |
29 | // 不存在父级,显示返回按钮
30 | if(window.parent === window) {
31 | document.querySelector('.return-btn')&&(document.querySelector('.return-btn').style.display = 'block');
32 | }
--------------------------------------------------------------------------------
/examples/direction-controller/Loading.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Loading.js
3 | * @author xiaohei
4 | * @date 2018/9/28
5 | * @description Loading文件
6 | */
7 |
8 | function Loading(){
9 | this.layer = ycc.layerManager.newLayer();
10 |
11 | this.layer.addUI(new Ycc.UI.Rect({
12 | rect:new Ycc.Math.Rect(0,0,stageW,stageH),
13 | color:"rgba(0,0,0,0.1)"
14 | }));
15 | this.layer.addUI(new Ycc.UI.SingleLineText({
16 | content:"正在加载...",
17 | rect:new Ycc.Math.Rect(0,stageH/2,stageW,20),
18 | xAlign:"center"
19 | }));
20 |
21 | this.hidden = function(){
22 | this.layer.show = false;
23 | };
24 |
25 | this.show = function(){
26 | this.layer.show = true;
27 | };
28 | }
--------------------------------------------------------------------------------
/examples/direction-controller/images/btn.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/direction-controller/images/btn.jpg
--------------------------------------------------------------------------------
/examples/direction-controller/images/fight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/direction-controller/images/fight.png
--------------------------------------------------------------------------------
/examples/direction-controller/images/jump.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/direction-controller/images/jump.png
--------------------------------------------------------------------------------
/examples/direction-controller/images/mario-fight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/direction-controller/images/mario-fight.png
--------------------------------------------------------------------------------
/examples/direction-controller/images/mario-walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/direction-controller/images/mario-walk.png
--------------------------------------------------------------------------------
/examples/direction-controller/images/mario.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/direction-controller/images/mario.png
--------------------------------------------------------------------------------
/examples/direction-controller/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 行走的马里奥
7 |
8 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/examples/direction-controller/main.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file main.js
3 | * @author xiaohei
4 | * @date 2018/9/28
5 | * @description main文件
6 | */
7 |
8 | if(!Ycc.utils.isMobile())
9 | throw new Error(alert('此示例只能在移动端查看!'));
10 |
11 | var canvas = document.createElement('canvas');
12 | console.log(document.documentElement.clientWidth,document.documentElement.clientHeight);
13 | canvas.width=document.documentElement.clientWidth;
14 | canvas.height=document.documentElement.clientHeight;
15 | document.body.appendChild(canvas);
16 |
17 |
18 | ///////////////////////////// 全局变量
19 | var ycc = new Ycc().bindCanvas(canvas);
20 | var stageW = ycc.getStageWidth();
21 | var stageH = ycc.getStageHeight();
22 | // 所有的图片资源
23 | var images = null;
24 | // 当前场景
25 | var currentScene = null;
26 | // loading窗
27 | var loading = new Loading();
28 | //////
29 |
30 |
31 |
32 |
33 | // 加载资源
34 | ycc.loader.loadResOneByOne([
35 | {name:"btn",url:"./images/btn.jpg"},
36 | {name:"fight",url:"./images/fight.png"},
37 | {name:"jump",url:"./images/jump.png"},
38 | {name:"mario",url:"./images/mario-walk.png"},
39 | {name:"marioFight",url:"./images/mario-fight.png"},
40 | ],function (lise,imgs) {
41 | console.log(imgs,222);
42 | images = imgs;
43 | loading.hidden();
44 | currentScene = new GameScene();
45 | ycc.layerManager.reRenderAllLayerToStage();
46 | });
47 |
48 | // 开启动画,每帧都更新场景
49 | ycc.ticker.start(60);
50 | ycc.ticker.addFrameListener(function () {
51 | currentScene && currentScene.update && currentScene.update();
52 | ycc.layerManager.reRenderAllLayerToStage();
53 | });
54 |
--------------------------------------------------------------------------------
/examples/game-calm-down/audio/bg.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-calm-down/audio/bg.mp3
--------------------------------------------------------------------------------
/examples/game-calm-down/audio/over.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-calm-down/audio/over.wav
--------------------------------------------------------------------------------
/examples/game-calm-down/audio/tap.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-calm-down/audio/tap.mp3
--------------------------------------------------------------------------------
/examples/game-calm-down/images/qr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-calm-down/images/qr.png
--------------------------------------------------------------------------------
/examples/game-calm-down/images/restart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-calm-down/images/restart.png
--------------------------------------------------------------------------------
/examples/game-calm-down/images/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-calm-down/images/start.png
--------------------------------------------------------------------------------
/examples/game-do-not-touch-white-rect/images/qr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-do-not-touch-white-rect/images/qr.png
--------------------------------------------------------------------------------
/examples/game-do-not-touch-white-rect/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 游戏-别踩白块
7 |
8 |
9 |
10 |
11 |
12 |
13 | 注:微信客户端扫一扫查看
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/game-super-mario/Loading.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Loading.js
3 | * @author xiaohei
4 | * @date 2018/9/28
5 | * @description Loading文件
6 | */
7 |
8 | function Loading(){
9 | /**
10 | * 正在加载下方的进度
11 | * @type {string}
12 | */
13 | this.textUI = new Ycc.UI.SingleLineText({
14 | content:'',
15 | fontSize:'12px',
16 | rect:new Ycc.Math.Rect(0,stageH/2+20,stageW,20),
17 | xAlign:"center",
18 | color:'red'
19 | });
20 |
21 | this.layer = ycc.layerManager.newLayer();
22 |
23 | this.layer.addUI(new Ycc.UI.Rect({
24 | rect:new Ycc.Math.Rect(0,0,stageW,stageH),
25 | color:"gray"
26 | }));
27 | this.layer.addUI(new Ycc.UI.SingleLineText({
28 | content:"正在加载...",
29 | rect:new Ycc.Math.Rect(0,stageH/2,stageW,20),
30 | xAlign:"center",
31 | color:'red'
32 | }));
33 | this.layer.addUI(this.textUI);
34 |
35 | this.hidden = function(){
36 | this.layer.show = false;
37 | };
38 |
39 | this.show = function(){
40 | this.layer.show = true;
41 | };
42 |
43 | this.updateText = function (text) {
44 | this.textUI.content = text;
45 | ycc.layerManager.reRenderAllLayerToStage();
46 | };
47 | }
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/bgm.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/bgm.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/dead1.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/dead1.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/dead2.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/dead2.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/jump.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/jump.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/start.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/start.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/touchCoin.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/touchCoin.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/touchFlower.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/touchFlower.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/touchMushroom.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/touchMushroom.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/touchWall.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/touchWall.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/victory.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/victory.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/加一条命.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/加一条命.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/地下.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/地下.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/城堡通关.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/城堡通关.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/audios/顶出蘑菇,花或星.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/audios/顶出蘑菇,花或星.mp3
--------------------------------------------------------------------------------
/examples/game-super-mario/game-super-mario-grunt-config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file game-super-mario-grunt-config.js
3 | * @author xiaohei
4 | * @date 2018/11/23
5 | * @description game-super-mario-grunt-config文件
6 | */
7 |
8 |
9 |
10 | // 根目录
11 | var root = './examples/game-super-mario/';
12 | // 目标根目录
13 | var destRoot = './examples/wx-minigame/examples/game-super-mario/';
14 |
15 | module.exports = {
16 | concat:{
17 | game_super_mario: {
18 | src: [
19 | // core
20 | // '../../build/ycc.js',
21 | // './lib/matter-js/matter.js',
22 | './Loading.js',
23 | './GameScene.js',
24 | './GameScene.ui.js',
25 | './level_1_1.js',
26 | './level_1_2.js',
27 | './level_1_3.js',
28 | './level_1_4.js',
29 | './main.js',
30 | ].map(function (t) { return root+t; }),
31 | dest: destRoot+'src.js'
32 | }
33 | },
34 | clean:{
35 | game_super_mario:{
36 | contents:[destRoot+"src.js",destRoot+"src.min.js"]
37 | }
38 | },
39 | uglify:{
40 | game_super_mario:{
41 | options: {
42 | sourceMap:false
43 | },
44 | files: [
45 | {
46 | expand: true,
47 | src: [destRoot+'src.js'],
48 | dest: destRoot,
49 | rename: function (dst, src) {
50 | return src.replace('.js', '.min.js');
51 | }
52 | }
53 | ]
54 | },
55 | },
56 | copy:{
57 | game_super_mario: {
58 | expand:true,cwd:"./build", src: '*.js', dest: destRoot+'../../build/'
59 | }
60 | }
61 |
62 | };
--------------------------------------------------------------------------------
/examples/game-super-mario/images/bg01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/bg01.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/bg02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/bg02.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/bg03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/bg03.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/bg04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/bg04.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/bg05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/bg05.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/btn.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/btn.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/bucket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/bucket.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/button.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/coin100.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/coin100.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/fight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/fight.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/flag.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/girl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/girl.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/jump.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/jump.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mario-down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mario-down.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mario-fight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mario-fight.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mario-jump.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mario-jump.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mario-touch-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mario-touch-flag.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mario-walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mario-walk.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mario.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mario.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/missile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/missile.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/mushroom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/mushroom.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/music.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/music.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/qr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/qr.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/wall-special-01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/wall-special-01.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/images/wall-special-02.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/wall-special-02.png
--------------------------------------------------------------------------------
/examples/game-super-mario/images/wall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/images/wall.png
--------------------------------------------------------------------------------
/examples/game-super-mario/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 游戏-超级玛丽
7 |
8 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/examples/game-super-mario/level-editor/css.css:
--------------------------------------------------------------------------------
1 | body{
2 | font-size: 0;
3 | position: relative;
4 | }
5 | #log{
6 | position: fixed;
7 | left: 0;
8 | top:0;
9 | z-index:999;
10 | width:100%;
11 | height:300px;
12 | overflow-y: scroll;
13 | font-size:12px;
14 | color:red;
15 | display: none;
16 | }
17 |
18 | button{
19 | background-color: #5bc0de;
20 | outline: none;
21 | border:none;
22 | padding:5px;
23 | border-radius: 3px;
24 | }
25 | button:hover{
26 | background-color:#2a6496;
27 | }
28 | input[type=text],input[type=number],select{
29 | height: 24px;
30 | line-height: 24px;
31 | outline: none;
32 | }
33 |
34 |
35 |
36 | body *{
37 | -webkit-transition: all .3s;
38 | -moz-transition: all .3s;
39 | -ms-transition: all .3s;
40 | -o-transition: all .3s;
41 | transition: all .3s;
42 | }
43 |
44 |
45 | #canvas{
46 | margin-top: 20px;
47 | text-align: center;
48 | }
49 |
50 | #canvas canvas{
51 | width:200px;
52 | border:1px solid #888;
53 | }
54 |
55 |
56 | #wrap{
57 | font-size:12px !important;
58 | }
59 | #start{
60 | margin-top: 20px;
61 | text-align: center;
62 | padding-bottom:20px;
63 | }
64 | #start .item{
65 | width:100px;
66 | display: inline;
67 | margin-top: 20px;
68 | }
69 | #level-name,#layerX{
70 | width:60px;
71 | }
72 |
73 | .tool-wrap{
74 | margin-left: 50%;
75 | }
76 | #tools{
77 | float: left;
78 | font-size:12px;
79 | margin-top:20px;
80 | margin-left: -360px;
81 | }
82 | #live-ui{
83 | max-height:200px;
84 | overflow-y: scroll;
85 | }
86 | #live-ui span{
87 | color:#2a6496;
88 | float: right;
89 | cursor: pointer;
90 | user-select: none;
91 | }
92 | #live-ui span:hover{
93 | color:#66afe9;
94 | }
95 |
96 | #tools .panel{
97 | float: left;
98 | min-height: 230px;
99 | margin-left: 20px;
100 | }
101 |
102 | .panel{
103 | width:200px;
104 | background-color: #ccc;
105 | padding:20px;
106 | }
107 | .panel-title{
108 | font-size: 14px;
109 | font-weight: bold;
110 | }
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | #props{
119 | display: none;
120 | position:relative;
121 | }
122 | #props .tool-prop{
123 | display: none;
124 | line-height: 30px;
125 | }
126 |
127 | #props input{
128 | width:60px;
129 | float: right;
130 | }
131 | #props .prop-ctrl-btn{
132 | position:absolute;
133 | bottom:20px;
134 | left:0;
135 | width:90%;
136 | text-align: right;
137 | }
138 |
139 |
140 | #tool-list{
141 | }
142 | #tool-list button{
143 | display: block;
144 | text-align: center;
145 | width:100%;
146 | margin-top: 1px;
147 | }
148 | #tool-list button[active]{
149 | background-color: #aaa;
150 | }
151 |
152 | #js{
153 | font-size: 12px;
154 | clear: both;
155 | word-break: break-all;
156 | }
157 |
158 | .clearfix:after{display:table;content:" ";clear:both;height: 0;visibility: hidden;}
159 |
160 |
161 | /*********************** 移动端布局 **************************/
162 | @media screen and (max-width:800px) {
163 | .panel{
164 | width:120px;
165 | padding:5px;
166 | }
167 | #props input{
168 | width:28px;
169 | }
170 | .tool-wrap{
171 | margin-left: 0;
172 | }
173 | #tools{
174 | float: left;
175 | font-size:12px;
176 | margin-top:5px;
177 | margin-left: 0;
178 | }
179 | #tools .panel{
180 | margin-left: 5px;
181 | }
182 | #live-ui-panel{
183 | width:90px;
184 | }
185 | #tool-list{
186 | width:60px;
187 | }
188 | #level-name, #layerX{
189 | width:40px;
190 | }
191 | #canvas canvas{
192 | width:150px;
193 | }
194 | body{
195 | padding-bottom:30px;
196 | }
197 | #start {
198 | margin-top: 5px;
199 | text-align: center;
200 | padding-bottom: 5px;
201 | }
202 | #canvas{
203 | margin-top: 5px;
204 | }
205 | }
206 |
--------------------------------------------------------------------------------
/examples/game-super-mario/level_1_1.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file level-1-1.js
3 | * @author xiaohei
4 | * @date 2018/10/15
5 | * @description level-1-1文件
6 | *
7 | * 关卡一:吃金币
8 | */
9 |
10 |
11 | (function (GameScene) {
12 |
13 |
14 | GameScene.prototype.level_1_1 = function () {
15 | this.levelCommonSetting();
16 |
17 | uiCreator.call(this);
18 |
19 | this.levelCommonEnd(1650);
20 | };
21 |
22 |
23 | function uiCreator(){
24 | this.newGround(0,150,450);
25 |
26 | // this.newGirl(220,150);
27 | this.newMushroom(220,180);
28 | this.newMushroom(260,180);
29 | this.newMushroom(300,180);
30 |
31 | this.newBucket(100,150);
32 | this.newCoin(100,300,1,4);
33 |
34 | this.newBucket(350,150);
35 |
36 | this.newCoin(380,300,1,1);
37 |
38 | this.newCoin(450,350,1,1);
39 |
40 | this.newGround(550,150,100);
41 | this.newCoin(550,350,1,2);
42 |
43 |
44 |
45 |
46 |
47 |
48 | // 创建一堵墙
49 | this.newWall(700,250,1,3);
50 | this.newCoin(700,450,1,5);
51 |
52 | this.newWall(850,400,1,3);
53 | this.newCoin(850,450,1,2);
54 |
55 | this.newWall(1050,50,1,3);
56 | this.newCoin(1050,250,1,5);
57 |
58 |
59 |
60 | this.newWall(1200,0,2,1);
61 | this.newWall(1240,0,3,1);
62 | this.newWall(1280,0,4,1);
63 | this.newWall(1320,0,5,1);
64 | this.newWall(1360,0,6,1);
65 | this.newWall(1400,0,7,1);
66 | this.newWall(1460,0,8,1);
67 |
68 | this.newWall(1560,0,10,1);
69 | // 添加几发导弹
70 | this.newMissile(300,300);
71 | this.newMissile(1300,400);
72 | this.newMissile(2300,500);
73 |
74 |
75 | }
76 |
77 |
78 |
79 | })(GameScene);
--------------------------------------------------------------------------------
/examples/game-super-mario/level_1_2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file level_1_2.js
3 | * @author xiaohei
4 | * @date 2018/10/23
5 | * @description level_1_2文件
6 | *
7 | * 关卡二:超长地图
8 | */
9 |
10 |
11 | (function (GameScene) {
12 |
13 | GameScene.prototype.level_1_2 = function () {
14 | this.levelCommonSetting();
15 |
16 | uiCreator.call(this);
17 |
18 | this.levelCommonEnd(4800);
19 | };
20 |
21 |
22 | function uiCreator(){
23 | this.newGround(0,150,500);
24 | this.newGround(600,150,500);
25 | this.newGround(1200,150,100);
26 | this.newGround(1400,150,100);
27 | this.newGround(1600,150,50);
28 | this.newGround(1700,150,50);
29 | this.newGround(1800,150,50);
30 |
31 | this.newWall(1900,200,1,4);
32 | this.newWall(2200,300,1,2);
33 | this.newWall(2400,400,1,3);
34 | this.newWall(2600,200,1,3);
35 | this.newWall(2700,100,1,3);
36 | this.newWall(2800,300,1,7);
37 |
38 | this.newGround(3000,150,500);
39 | this.newGround(3600,150,500);
40 |
41 | this.newWall(4100,200,1,8);
42 | this.newWall(4400,300,1,3);
43 | this.newWall(4600,400,1,2);
44 |
45 | this.newGround(4800,150,500);
46 |
47 |
48 |
49 | this.newMushroom(220,180);
50 | this.newMushroom(260,180);
51 | this.newMushroom(300,180);
52 |
53 | this.newMushroom(1220,180);
54 | this.newMushroom(1260,180);
55 |
56 | this.newMushroom(2220,180);
57 | this.newMushroom(2260,180);
58 |
59 |
60 | this.newMushroom(3220,180);
61 | this.newMushroom(3260,180);
62 |
63 | this.newMushroom(4220,180);
64 | this.newMushroom(4260,180);
65 |
66 |
67 | this.newCoin(100,300,1,3);
68 | this.newCoin(380,300,4,1);
69 | this.newCoin(450,350,2,1);
70 | this.newCoin(1200,500,1,3);
71 | this.newCoin(1800,400,1,3);
72 | this.newCoin(2100,300,4,3);
73 | this.newCoin(3100,300,1,3);
74 | this.newCoin(4100,300,1,3);
75 |
76 | // 添加几发导弹
77 | this.newMissile(900,400);
78 | this.newMissile(1300,300);
79 | this.newMissile(1900,600);
80 | this.newMissile(3300,500);
81 |
82 | }
83 |
84 | })(GameScene);
--------------------------------------------------------------------------------
/examples/game-super-mario/level_1_3.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file level_1-3.js
3 | * @author xiaohei
4 | * @date 2018/10/25
5 | * @description level_1-3文件
6 | */
7 |
8 |
9 | (function (GameScene) {
10 |
11 |
12 | GameScene.prototype.level_1_3 = function () {
13 | this.levelCommonSetting();
14 |
15 | uiCreator.call(this);
16 |
17 | this.levelCommonEnd(1800);
18 | };
19 |
20 |
21 | function uiCreator(){
22 | // 临时变量
23 | var x=0;
24 | var marginBottom=150;
25 | var width = 200;
26 |
27 | this.newWall(0,200,1,10,[[0,2,1]]);
28 |
29 | this.newWall(150,350,2,5,[[1,2,1,3]]);
30 |
31 | this.newMushroom(350,500);
32 |
33 |
34 | /**
35 | *
36 | * -----
37 | * | ^^^ |
38 | * _________
39 | */
40 | x=500;
41 | marginBottom=150;
42 | width=400;
43 | this.newGround(x,marginBottom,width);
44 | this.newBucket(x,marginBottom);
45 | this.newBucket(x+width-80,marginBottom,1,80);
46 | this.newWall(x+100,marginBottom+200,1,4,[[0,1,1,1],[0,2,1,1]]);
47 | this.newCoin(x+150,marginBottom+250,1,3);
48 | this.newMushroom(x+100,marginBottom);
49 | this.newMushroom(x+150,marginBottom);
50 | this.newMushroom(x+200,marginBottom);
51 |
52 |
53 | /**
54 | * __
55 | * __
56 | * __
57 | */
58 | x=1000;
59 | marginBottom = 150;
60 | width=700;
61 | this.newWall(x,marginBottom,1,5);
62 | this.newWall(x+250,marginBottom+100,1,5);
63 | this.newWall(x+500,marginBottom+200,1,5);
64 | this.newMushroom(x+200,marginBottom+200);
65 | this.newCoin(x,marginBottom+100,1,3);
66 | this.newCoin(x+250,marginBottom+100+100,1,3);
67 | this.newCoin(x+500,marginBottom+200+100,1,3);
68 | }
69 |
70 |
71 | })(GameScene);
--------------------------------------------------------------------------------
/examples/game-super-mario/level_1_4.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file level_1_4.js
3 | * @author xiaohei
4 | * @date 2018/11/15
5 | * @description level_1_4文件
6 | */
7 |
8 | (function (GameScene) {
9 |
10 | GameScene.prototype.level_1_4 = function () {
11 | this.levelCommonSetting();
12 | uiCreator.call(this);
13 | this.levelCommonEnd(5100);
14 | };
15 |
16 | function uiCreator() {
17 | this.newGround(0,150,300);this.newWall(126,260,1,3,[[0,1,1,3]]);this.newWall(370,260,1,3,[]);this.newCoin(382,400,1,3);this.newWall(556,360,1,3,[]);this.newGround(676,150,300);this.newCoin(770,300,1,3);this.newBucket(864,150,1,80,90);this.newGround(1008,150,300);this.newBucket(1008,150,1,80,90);this.newBucket(1198,150,1,80,90);this.newMushroom(1112,150);this.newWall(1334,260,1,3,[]);this.newWall(1500,160,1,3,[]);this.newCoin(1500,260,1,5);this.newWall(1690,260,1,3,[]);this.newCoin(1692,400,1,3);this.newGround(1850,150,600);this.newBucket(1858,150,1,80,90);this.newBucket(2360,150,1,80,90);this.newMushroom(2080,150);this.newMushroom(2136,150);this.newMushroom(2216,150);this.newMushroom(1986,150);this.newMushroom(1986,310);this.newGround(2498,150,30);this.newGround(2586,150,30);this.newGround(2686,150,30);this.newGround(2788,150,100);this.newWall(2934,260,1,3,[]);this.newWall(3092,360,1,3,[]);this.newWall(3298,460,1,3,[]);this.newWall(3492,560,1,3,[]);this.newGround(3484,150,300);this.newWall(3484,260,1,3,[]);this.newBucket(3562,150,1,80,90);this.newMushroom(3690,150);this.newMushroom(3762,150);this.newWall(3792,260,1,3,[[0,1,1,10]]);this.newWall(2020,260,1,6,[[0,1,1,5]]);this.newGround(3926,150,300);this.newCoin(4128,200,1,3);this.newGround(4346,150,300);this.newWall(4646,260,1,3,[]);this.newWall(4770,0,5,1,[]);this.newWall(4810,0,6,1,[]);this.newWall(4850,0,7,1,[]);this.newWall(4890,0,8,1,[]);this.newWall(4930,0,9,1,[]);this.newWall(4970,0,10,2,[]);
18 | }
19 |
20 |
21 | })(GameScene);
22 |
23 |
--------------------------------------------------------------------------------
/examples/game-super-mario/material/animals.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/material/animals.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/material/icon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/material/icon.jpg
--------------------------------------------------------------------------------
/examples/game-super-mario/material/mario.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/game-super-mario/material/mario.png
--------------------------------------------------------------------------------
/examples/game-super-mario/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "game-super-mario",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "main.js",
6 | "directories": {
7 | "lib": "lib"
8 | },
9 | "scripts": {
10 | "test": "echo \"Error: no test specified\" && exit 1",
11 | "build": "grunt build"
12 | },
13 | "author": "",
14 | "license": "ISC",
15 | "devDependencies": {
16 | "grunt": "^1.0.3",
17 | "grunt-contrib-clean": "^2.0.0",
18 | "grunt-contrib-concat": "^1.0.1",
19 | "grunt-contrib-uglify": "^4.0.0",
20 | "grunt-contrib-watch": "^1.1.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/graph/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 图的示例
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例用于展示Ycc的图结构Ycc.Graph。
19 | 2、示例是一个无向图,图的遍历都是从节点1开始的。
20 | 3、下面提供了图的深度遍历和广度遍历,点击按钮即可查看遍历结果。
21 | 4、使用了方法createUnDirectedGraph创建无向图。
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | 遍历结果:
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/examples/hello-ycc/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Hello,Ycc!
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
示例说明:
19 |
20 | 这个示例是教程里最简单的一个,仅仅显示了一个居中文本"Hello,Ycc!"。
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/image-loader/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | image loader
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
示例说明:
19 |
20 | 这个示例只是简单的调用了加载器 loadImgOneByOne 方法。
21 |
22 |
23 |
24 |
功能说明:
25 |
26 | 无论你怎么刷新页面,图片的加载顺序都是一样的。
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/examples/map-of-china/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 多边形-中国地图
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例使用底层提供的多边形绘制一个中国地图。
19 | 2、地图的各个区域都是可以点击的。
20 | 3、此地图支持移动端和PC端。
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/mirror-animation/btn.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/mirror-animation/btn.jpg
--------------------------------------------------------------------------------
/examples/mirror-animation/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/examples/paper-selector/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 框题操作
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
示例说明:
19 |
20 | 1、这个示例展示框选操作,实质是一个框选的UI。
21 | 2、每次点击框选按钮后,PC端可以在绘图区拖动鼠标框选,移动端可以拖拽框选。
22 | 3、框选结束后,可以拖动红色区域改变选区位置,也可以拖动边角更改选框大小。
23 | 4、选区下方可以添加按钮,这里的代码被注释了。
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/examples/paper-selector/paper.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/paper-selector/paper.gif
--------------------------------------------------------------------------------
/examples/piano-audio/31!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/31!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/32!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/32!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/33!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/33!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/34!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/34!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/35!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/35!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/36!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/36!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/37!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/37!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/41!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/41!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/42!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/42!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/43!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/43!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/44!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/44!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/45!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/45!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/46!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/46!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/47!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/47!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/51!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/51!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/52!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/52!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/53!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/53!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/54!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/54!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/55!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/55!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/56!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/56!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/57!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/57!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/61!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/61!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/62!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/62!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/63!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/63!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/64!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/64!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/65!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/65!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/66!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/66!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/67!.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/piano-audio/67!.mp3
--------------------------------------------------------------------------------
/examples/piano-audio/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 音频示例
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例展示系统的音频播放功能。
19 | 2、点击播放,一首《那女孩对我说》送给你。
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/examples/polygon-of-star/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 多边形示例
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例展示系统的多边形功能。
19 | 2、下面是用多边形来绘制的五角星。
20 | 3、可以通过五角星的控制点来变换多边形的形状。
21 | 4、还可以点击图形区域触发点击事件,区域内判断采用光线投射原理
22 | 5、若未采用noneZeroMode,只能点击五角星的各个角落,并不能点击五角星内部的五边形
23 | 6、第一个五角星未采用noneZeroMode
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/render-by-json/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 根据json数组绘制界面
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 这个示例仅仅调用系统的renderAllLayerByJsonArray渲染舞台。
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | 这个示例的大致意思是:
两个图层,每个图层三个UI。
28 |
29 | 示例json数组如下:
30 |
31 | [{
32 | option:{
33 | enableEventManager:true,
34 | show:true
35 | },
36 | ui:[{
37 | type:Ycc.UI.SingleLineText.name,
38 | option:{content:"这两个UI添加了事件监听",rect:new Ycc.Math.Rect(10,10,0,0)}
39 | },{
40 | type:Ycc.UI.Circle.name,
41 | option:{
42 | point:new Ycc.Math.Dot(30,50),
43 | r:20,
44 | ontap:function (e) {
45 | alert('点我干啥!我是圆 Circle!');
46 | }
47 | }
48 | },{
49 | type:Ycc.UI.Ellipse.name,
50 | option:{
51 | point:new Ycc.Math.Dot(120,50),
52 | width:60,
53 | height:30,
54 | ontap:function (e) {
55 | alert('点我干啥!我是椭圆 Ellipse!');
56 | }
57 | }
58 | }]
59 | },{
60 | option:{
61 | enableEventManager:false,
62 | show:true
63 | },
64 | ui:[{
65 | type:Ycc.UI.SingleLineText.name,
66 | option:{content:"这两个UI添加了事件也没用",rect:new Ycc.Math.Rect(10,100,0,0)}
67 | },{
68 | type:Ycc.UI.Circle.name,
69 | option:{
70 | point:new Ycc.Math.Dot(30,140),
71 | r:20,
72 | ontap:function (e) {
73 | alert('点我也没用!');
74 | }
75 | }
76 | },{
77 | type:Ycc.UI.Ellipse.name,
78 | option:{
79 | point:new Ycc.Math.Dot(100,140),
80 | width:60,
81 | height:30,
82 | ontap:function (e) {
83 | alert('点我也没用!');
84 | }
85 | }
86 | }]
87 | }]
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/examples/scroller-rect/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 滚动区域
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
示例说明:
19 |
20 | 1、这个示例展示系统的滚动区UI。
21 | 2、绿色区域为滚动区,可以上下拖动。
22 | 3、滚动区内有50条数据,点击他们可以改变色值。
23 | 4、需要注意:滚动区内的点击事件和滚动区的滑动事件是有重叠的,故滚动区内应该尽量避免存在大范围的可点击区域。
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/sequence-frame-animation/images/mario-walk.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/sequence-frame-animation/images/mario-walk.png
--------------------------------------------------------------------------------
/examples/sequence-frame-animation/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 序列帧动画
7 |
8 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/examples/simple-editor/cross.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/simple-editor/cross.png
--------------------------------------------------------------------------------
/examples/simple-editor/paper.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/simple-editor/paper.jpg
--------------------------------------------------------------------------------
/examples/simple-editor/tick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/simple-editor/tick.png
--------------------------------------------------------------------------------
/examples/smooth-line/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 折线平滑
6 |
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例展示系统的折线UI。
19 | 2、折线可以通过设置smooth属性来让折线变为曲线。
20 | 3、下图白色曲线为平滑后的曲线。
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/style.css:
--------------------------------------------------------------------------------
1 |
2 | *{
3 | margin: 0;
4 | padding:0;
5 | }
6 | canvas{
7 | background-color: #ccc;
8 | }
9 | .tip{
10 |
11 | }
12 |
13 | .return-btn{
14 | display: none;
15 | clear: both; padding: 10px 0;
16 | }
17 | .return-btn a{
18 | text-align: center;width: 100px; height: 30px; display: block; background-color: #ccc; line-height: 30px;
19 | }
20 |
21 | pre{
22 | background-color: #ccc;
23 | max-width: 100%;
24 | overflow-x: auto;
25 | }
26 |
27 | @media screen and (max-width: 640px) {
28 | .return-btn{
29 | display: block;
30 | }
31 | }
--------------------------------------------------------------------------------
/examples/timer-animation/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 四处碰壁的小球
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 这个示例是一个小球的碰壁反弹动画,用到了系统的ticker模块,产生帧动画。
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/tree/dir-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/tree/dir-logo.png
--------------------------------------------------------------------------------
/examples/ui-children/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/ui-children/bg.png
--------------------------------------------------------------------------------
/examples/ui-children/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | UI嵌套
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例展示UI的嵌套能力。
19 | 2、示例的所有UI都是红色方框的子UI,它们的坐标都是相对于方框的相对坐标。
20 | 3、注意:红色方框并不会因为子UI的范围超出而改变大小。
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/ui-children/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/ui-children/logo.jpg
--------------------------------------------------------------------------------
/examples/ui-component/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | UI组件测试
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 这个示例展示系统的UI组件
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/ui-ellipse/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 椭圆测试
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例是一个椭圆的旋转动画,用于展示UI的矩形包裹区域。
19 | 2、椭圆旋转过程中,UI的包裹区域会实时的计算,UI的点击事件或者其他事件会直接作用于这个包裹区域。
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/ui-event/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | UI事件的示例
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例是一个可以拖拽的文本UI,用于展示UI的事件。
19 | 2、PC端可以在拖动鼠标改变文本的位置,移动端可以拖拽改变文本的位置。
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/examples/ui-test/broken-line.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 折线BrokenLine测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的折线UI。
14 | 2、折线UI继承自多边形,背景、旋转、坐标转换等方法都是可用的。
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/ui-test/circle.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 圆Circle测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的圆UI。
14 | 2、蓝色圆经过了旋转,其旋转中心通过anchorX、anchorY设置在圆外的(0,0)位置,旋转了90度。
15 | 3、红色圆其旋转中心通过anchorX、anchorY设置在圆上最左侧的位置,旋转了180度。
16 | 4、虚线标注了UI旋转、平移之前的位置。
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/ui-test/ellipse.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 椭圆Ellipse测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的圆UI。
14 | 2、蓝色椭圆绕其中心旋转了90度,理解为自转。
15 | 3、红色绕0,0旋转了45度,理解为公转。
16 | 4、请结合地球和太阳的关系理解自转和公转。
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/ui-test/image.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 图片Image测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的图片UI。
14 | 2、图一Image经过了旋转,其旋转中心通过anchorX、anchorY设置
15 | 3、图二Image使用了repeat模式,并且通过mirror参数将图片进行了镜像
16 | 4、虚线标注了UI旋转、平移之前的位置。
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/examples/ui-test/img/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/ui-test/img/bg.png
--------------------------------------------------------------------------------
/examples/ui-test/img/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/ui-test/img/logo.jpg
--------------------------------------------------------------------------------
/examples/ui-test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | UI图形测试
7 |
8 |
9 |
10 |
15 |
16 |
示例说明:
17 |
18 | 1、这个示例展示系统的UI,每个UI都绘制了红色的容纳区。
19 | 2、这些UI包括:单行文本、多行文本、图片、矩形、椭圆、线条、九宫格等。
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/examples/ui-test/line.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 线段Line测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的线段UI。
14 | 2、线段实质上也是多边形,只要宽度足够。
15 | 3、下面绘制了一个线段宽度为3的线段
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/ui-test/multi-line-text.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 多行文本
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的多行文本UI。
14 | 2、多行文本继承自多边形UI,同样支持旋转,虚线标注了UI旋转、平移之前的位置。
15 | 3、多行文本采用\r\n换行。
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/ui-test/polygon.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 多边形Polygon测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的多边形UI。
14 | 2、蓝色多边形经过了旋转,其旋转中心通过anchorX、anchorY。
15 | 3、UI的x、y值可以理解为UI的偏移量,虚线标注了UI旋转、平移之前的位置。
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/ui-test/rect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 方块Rect测试示例
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的方块UI。
14 | 2、蓝色方块经过了旋转,其旋转中心通过anchorX、anchorY。
15 | 3、UI的x、y值可以理解为UI的偏移量,虚线标注了UI旋转、平移之前的位置。
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/ui-test/single-line-text.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 单行文本
6 |
7 |
8 |
9 |
10 |
11 |
示例说明:
12 |
13 | 1、这个示例展示系统的单行文本UI。
14 | 2、蓝色方块经过了旋转,其旋转中心通过anchorX、anchorY。
15 | 3、UI的x、y值可以理解为UI的偏移量,虚线标注了UI旋转、平移之前的位置。
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/examples/wx-minigame/README.md:
--------------------------------------------------------------------------------
1 | ## quickstart
2 |
3 | ## 源码目录介绍
4 | ```
5 | ./js
6 | ├── base // 定义游戏开发基础类
7 | │ ├── animatoin.js // 帧动画的简易实现
8 | │ ├── pool.js // 对象池的简易实现
9 | │ └── sprite.js // 游戏基本元素精灵类
10 | ├── libs
11 | │ ├── symbol.js // ES6 Symbol简易兼容
12 | │ └── weapp-adapter.js // 小游戏适配器
13 | ├── npc
14 | │ └── enemy.js // 敌机类
15 | ├── player
16 | │ ├── bullet.js // 子弹类
17 | │ └── index.js // 玩家类
18 | ├── runtime
19 | │ ├── background.js // 背景类
20 | │ ├── gameinfo.js // 用于展示分数和结算界面
21 | │ └── music.js // 全局音效管理器
22 | ├── databus.js // 管控游戏状态
23 | └── main.js // 游戏入口主函数
24 |
25 | ```
--------------------------------------------------------------------------------
/examples/wx-minigame/examples/timer-animation.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | var width = canvas.width;
7 | var height = canvas.height;
8 |
9 | var ycc = new Ycc();
10 | ycc.bindCanvas(canvas);
11 | ycc.ticker.start();
12 |
13 | var layer = ycc.layerManager.newLayer({ enableFrameEvent: true });
14 |
15 | layer.addUI(new Ycc.UI.Rect({
16 | rect: new Ycc.Math.Rect(0, 0, ycc.getStageWidth(), ycc.getStageHeight()),
17 | color:'red'
18 | }));
19 |
20 | var x = 0, y = 0;
21 | var stepPx = 8;
22 | var left = true;
23 | var topTo = true;
24 | var update = function () {
25 | if (x <= 0) left = true;
26 | if (x >= width) left = false;
27 | if (y <= 0) topTo = true;
28 | if (y >= height) topTo = false;
29 | if (left)
30 | x += stepPx;
31 | else
32 | x -= stepPx;
33 |
34 | if (topTo)
35 | y += stepPx;
36 | else
37 | y -= stepPx;
38 | };
39 | var circle = new Ycc.UI.Circle({ point: new Ycc.Math.Dot(x, y), r: 20 });
40 | layer.addUI(circle);
41 | ycc.layerManager.reRenderAllLayerToStage();
42 |
43 | layer.onFrameComing = function () {
44 | console.log('frameComing...',Date.now());
45 | update();
46 | layer.clear();
47 | circle.point.x = x;
48 | circle.point.y = y;
49 | ycc.layerManager.reRenderAllLayerToStage();
50 | }
--------------------------------------------------------------------------------
/examples/wx-minigame/examples/ui-event.js:
--------------------------------------------------------------------------------
1 |
2 | var ycc = new Ycc();
3 | ycc.bindCanvas(canvas);
4 | ycc.ticker.start();
5 |
6 |
7 | // 新建图层
8 | var layer = ycc.layerManager.newLayer({ enableFrameEvent: true, enableEventManager: true });
9 | // 新建多行文本的UI
10 | var ui = new Ycc.UI.MultiLineText({
11 | content: "我是 可以拖拽的 多行文本框 测试文字 测试文字 测试文字 测试文字 01234567",
12 | rect: new Ycc.Math.Rect(100, 100, 100, 100),
13 | wordBreak: "break-word",
14 | overflow: "auto",
15 | color: 'red'
16 | });
17 | // 添加至图层
18 | layer.addUI(ui);
19 |
20 | // 全部绘制
21 | ycc.layerManager.reRenderAllLayerToStage();
22 |
23 |
24 | // 拖拽
25 | var startPos = null,
26 | startRect = null;
27 | ui.ondragstart = function (e) {
28 | startPos = new Ycc.Math.Dot(e);
29 | startRect = new Ycc.Math.Rect(ui.rect);
30 | console.log(e, startPos, startRect);
31 | };
32 | ui.ondragging = function (e) {
33 | // console.log("我是", this.yccClass.name, "我", e.type, e);
34 | ui.rect.x = startRect.x + e.x - startPos.x;
35 | ui.rect.y = startRect.y + e.y - startPos.y;
36 | };
37 |
38 | layer.onFrameComing = function () {
39 | ycc.layerManager.reRenderAllLayerToStage();
40 | };
41 |
--------------------------------------------------------------------------------
/examples/wx-minigame/game.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | wx.setPreferredFramesPerSecond(60);
5 |
6 | require('./js/libs/weapp-adapter');
7 |
8 | window.Matter = require('./examples/game-super-mario/lib/matter-js/matter.js');
9 |
10 | window.Ycc = require('./build/ycc.js');
11 |
12 | require('./examples/game-super-mario/src.js');
13 |
14 | // require('./examples/ui-event.js');
15 | // require('./examples/timer-animation.js');
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/examples/wx-minigame/game.json:
--------------------------------------------------------------------------------
1 | {
2 | "deviceOrientation": "portrait"
3 | }
4 |
--------------------------------------------------------------------------------
/examples/wx-minigame/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件。",
3 | "setting": {
4 | "urlCheck": false,
5 | "es6": true,
6 | "postcss": true,
7 | "minified": true,
8 | "newFeature": true
9 | },
10 | "compileType": "game",
11 | "libVersion": "1.9.94",
12 | "appid": "wxa2e24ec8a522aad9",
13 | "projectname": "mario-super-man",
14 | "simulatorType": "wechat",
15 | "simulatorPluginLibVersion": {},
16 | "condition": {
17 | "search": {
18 | "current": -1,
19 | "list": []
20 | },
21 | "conversation": {
22 | "current": -1,
23 | "list": []
24 | },
25 | "game": {
26 | "currentL": -1,
27 | "list": []
28 | },
29 | "miniprogram": {
30 | "current": -1,
31 | "list": []
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/examples/zgh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/examples/zgh.png
--------------------------------------------------------------------------------
/jsdoc.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var packageJson = require('./package.json');
4 | module.exports = {
5 | "tags": {
6 | "allowUnknownTags" : true
7 | },
8 | "templates": {
9 | "applicationName": "Ycc Engine v" + packageJson.version + " API文档",
10 | "meta": {
11 | "title": "Ycc Engine API文档",
12 | "description": "",
13 | "keyword": ""
14 | },
15 | "linenums": false
16 | }
17 | };
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | demo/dist/
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/Gruntfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * http://gruntjs.com/configuring-tasks
3 | */
4 | module.exports = function (grunt) {
5 | var path = require('path');
6 | var DEMO_PATH = 'demo/dist';
7 | var DEMO_SAMPLE_PATH = 'demo/sample';
8 |
9 | grunt.initConfig({
10 | pkg: grunt.file.readJSON('package.json'),
11 |
12 | connect: {
13 | options: {
14 | hostname: '*'
15 | },
16 | demo: {
17 | options: {
18 | port: 8000,
19 | base: DEMO_PATH,
20 | middleware: function (connect, options) {
21 | return [
22 | require('connect-livereload')(),
23 | connect.static(path.resolve(options.base))
24 | ];
25 | }
26 | }
27 | }
28 | },
29 |
30 | watch: {
31 | options: {
32 | livereload: true
33 | },
34 | less: {
35 | files: ['less/**/*.less'],
36 | tasks: ['less']
37 | },
38 |
39 | lesscopy: {
40 | files: ['static/styles/jaguar.css'],
41 | tasks: ['copy:css']
42 | },
43 |
44 | jscopy: {
45 | files: ['static/scripts/main.js'],
46 | tasks: ['copy:js']
47 | },
48 |
49 | jsdoc: {
50 | files: ['**/*.tmpl', '*.js'],
51 | tasks: ['jsdoc']
52 | },
53 |
54 | demo: {
55 | files: ['demo/sample/**/*.js'],
56 | tasks: ['demo']
57 | }
58 | },
59 |
60 | clean: {
61 | demo: {
62 | src: DEMO_PATH
63 | }
64 | },
65 |
66 | jsdoc: {
67 | demo: {
68 | src: [
69 | DEMO_SAMPLE_PATH + '/**/*.js',
70 |
71 | // You can add README.md file for index page at documentations.
72 | 'README.md'
73 | ],
74 | options: {
75 | verbose: true,
76 | destination: DEMO_PATH,
77 | configure: 'conf.json',
78 | template: './',
79 | 'private': false
80 | }
81 | }
82 | },
83 |
84 | less: {
85 | dist: {
86 | src: 'less/**/jaguar.less',
87 | dest: 'static/styles/jaguar.css'
88 | }
89 | },
90 |
91 | copy: {
92 | css: {
93 | src: 'static/styles/jaguar.css',
94 | dest: DEMO_PATH + '/styles/jaguar.css'
95 | },
96 |
97 | js: {
98 | src: 'static/scripts/main.js',
99 | dest: DEMO_PATH + '/scripts/main.js'
100 | }
101 | }
102 | });
103 |
104 | // Load task libraries
105 | [
106 | 'grunt-contrib-connect',
107 | 'grunt-contrib-watch',
108 | 'grunt-contrib-copy',
109 | 'grunt-contrib-clean',
110 | 'grunt-contrib-less',
111 | 'grunt-jsdoc',
112 | ].forEach(function (taskName) {
113 | grunt.loadNpmTasks(taskName);
114 | });
115 |
116 | // Definitions of tasks
117 | grunt.registerTask('default', 'Watch project files', [
118 | 'demo',
119 | 'connect:demo',
120 | 'watch'
121 | ]);
122 |
123 | grunt.registerTask('demo', 'Create documentations for demo', [
124 | 'less',
125 | 'clean:demo',
126 | 'jsdoc:demo'
127 | ]);
128 | };
129 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Sangmin, Shim
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/README.md:
--------------------------------------------------------------------------------
1 | Jaguar.js template for JSDoc 3
2 | ---
3 | - [Jaguar.js](https://davidshimjs.github.io/jaguarjs/)
4 | - [Jaguar.js Documentations](https://davidshimjs.github.io/jaguarjs/doc/)
5 | - [JSDoc3](https://github.com/jsdoc3/jsdoc)
6 | - [JSDoc3 API Documentations](http://usejsdoc.org)
7 |
8 | Usage
9 | ---
10 | 1. If you want to create documentations with sample files, you can use commands below.
11 | ```
12 | $ npm install
13 | $ grunt demo
14 | ```
15 |
16 | 2. You can see any output related jsdoc process with a `--debug` flag.
17 | ```
18 | $ grunt demo --debug
19 | ```
20 |
21 | 3. If you already have jsdoc system, you can use this project as jsdoc template.
22 | ```
23 | $ jsdoc -t `project folder` -c `configuration file` `source files` `README.md file`
24 | ```
25 |
26 | conf.json
27 | ---
28 | You can set options for customizing your documentations.
29 |
30 | ```
31 | "templates": {
32 | "applicationName": "Demo",
33 | "disqus": "",
34 | "googleAnalytics": "",
35 | "openGraph": {
36 | "title": "",
37 | "type": "website",
38 | "image": "",
39 | "site_name": "",
40 | "url": ""
41 | },
42 | "meta": {
43 | "title": "",
44 | "description": "",
45 | "keyword": ""
46 | },
47 | "linenums": true
48 | }
49 | ```
50 |
51 | License
52 | ---
53 | This project under the MIT License. and this project refered by default template for JSDoc 3.
54 |
55 | [](https://bitdeli.com/free "Bitdeli Badge")
56 |
57 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/conf.json:
--------------------------------------------------------------------------------
1 | {
2 | "tags": {
3 | "allowUnknownTags" : true
4 | },
5 | "plugins": ["plugins/markdown"],
6 | "templates": {
7 | "cleverLinks": true,
8 | "monospaceLinks": true,
9 | "default": {
10 | "outputSourceFiles" : true
11 | },
12 | "applicationName": "Demo",
13 | "disqus": "",
14 | "googleAnalytics": "",
15 | "openGraph": {
16 | "title": "",
17 | "type": "website",
18 | "image": "",
19 | "site_name": "",
20 | "url": ""
21 | },
22 | "meta": {
23 | "title": "",
24 | "description": "",
25 | "keyword": ""
26 | },
27 | "linenums": false
28 | },
29 | "markdown": {
30 | "parser": "gfm",
31 | "hardwrap": true,
32 | "tags": ["examples"]
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/demo/sample/Car.js:
--------------------------------------------------------------------------------
1 | (function (w) {
2 | /**
3 | * quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
4 | consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
5 | * @class
6 | * @name namespace.Car
7 | */
8 | w.namespace.Car = function () {
9 | };
10 |
11 | w.namespace.Car.prototype = /** @lends namespace.Car.prototype */{
12 | /**
13 | * Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
14 | */
15 | testMethod: function () {
16 | },
17 |
18 | testMethodUnNotated: function () {
19 | },
20 |
21 | testEvent: function () {
22 | /**
23 | * tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
24 | * @name namespace.Car#testEvent
25 | * @event
26 | * @param {Event} e
27 | */
28 | test.trigger();
29 | }
30 | };
31 | })(window);
32 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/demo/sample/Child.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
3 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam
4 | * @class
5 | * @extends Parent
6 | */
7 | var Child = function () {
8 | };
9 |
10 | Child.prototype = /** @lends Child.prototype */{
11 | /**
12 | * cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidata
13 | * @property {Boolean}
14 | */
15 | testPropertyInChild: '',
16 |
17 | /**
18 | * cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
19 | */
20 | testMethodInChild: function (paramUnNotation) {
21 | return {};
22 | },
23 |
24 | /**
25 | * proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
26 | * @return {Object} result
27 | * @return {String} [result.property]
28 | * @return {Number} result.property2=123 cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
29 | */
30 | returnObject: function () {
31 | }
32 | };
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/demo/sample/Namespace.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @namespace
3 | */
4 | var namespace = namespace || {};
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/demo/sample/Parent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
3 | tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam
4 | * @class
5 | */
6 | var Parent = function () {
7 | };
8 |
9 | Parent.prototype = /** @lends Parent.prototype */{
10 | /**
11 | * cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidata
12 | * @property {String}
13 | */
14 | testProperty: '',
15 |
16 | /**
17 | * Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
18 | * @param {String|String[]} [paramA=Default Value] tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam
19 | * @param {namespace.Car} [paramB] quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
20 | * @param {Function} [paramCallback]
21 | * @param {String} paramCallback.firstParam
22 | * @param {String} paramCallback.secondParam
23 | * @return {Array|Object} Return value as non-object type. (or an object without properties)
24 | */
25 | testMethod: function (paramA, paramB, paramCallback) {
26 | return {};
27 | },
28 |
29 | /**
30 | * This method will return object value.
31 | * @return {Object} test returns object.
32 | * @return {Boolean} test.foo property description
33 | * @return {Number} test.bar optional property
34 | */
35 | testReturnValue: function () {
36 | },
37 |
38 | /**
39 | * @return Plain Text without type definition
40 | */
41 | testReturnPlainText: function () {
42 | },
43 |
44 | /**
45 | * @example
46 | * JSDoc3 Captions
47 | * var a = 0;
48 | *
49 | * for (var i = 0; i < 10; i++) {
50 | * a++;
51 | * }
52 | *
53 | * @example
54 | * jaguarjs-doc uses markdown style.
55 | *
56 | * ```
57 | * var a = 0;
58 | *
59 | * for (var i = 0; i < 10; i++) {
60 | * a++;
61 | * }
62 | * ```
63 | */
64 | testExample: function () {
65 | }
66 | };
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/less/common.less:
--------------------------------------------------------------------------------
1 | @navWidth: 250px;
2 | @colorSubtitle: rgb(119, 156, 52);
3 | @colorRed: rgb(238, 125, 125);
4 | @colorLink: #2a6496;
5 | @colorBgNavi: #1a1a1a;
6 |
7 | .font-description () {
8 | font-family: "freight-text-pro",Georgia,Cambria,"Times New Roman",Times,serif
9 | }
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/less/footer.less:
--------------------------------------------------------------------------------
1 | @import "common.less";
2 |
3 | footer {
4 | margin: 15px 0;
5 | padding-top: 15px;
6 | border-top: 1px solid #e1e1e1;
7 | .font-description();
8 | font-size: 0.8em;
9 | color: gray;
10 | }
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/less/jaguar.less:
--------------------------------------------------------------------------------
1 | @import "common.less";
2 |
3 | // normalize
4 | html, body {
5 | font: 1em "jaf-bernino-sans","Lucida Grande","Lucida Sans Unicode","Lucida Sans",Geneva,Verdana,sans-serif;
6 | background-color: #fff;
7 | }
8 | ul, ol {
9 | margin: 0;
10 | padding: 0;
11 | }
12 | li {
13 | list-style-type: none;
14 | }
15 |
16 | #wrap {
17 | position: relative;
18 | }
19 |
20 | @import "navigation.less";
21 | @import "main.less";
22 | @import "footer.less";
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/less/navigation.less:
--------------------------------------------------------------------------------
1 | @import "common.less";
2 |
3 | ::-webkit-scrollbar {
4 | width: 8px;
5 | background-color: transparent;
6 | }
7 |
8 | ::-webkit-scrollbar-thumb {
9 | background-color: gray;
10 | border-radius: 4px;
11 | }
12 |
13 | .navigation {
14 | position: fixed;
15 | float: left;
16 | width: @navWidth;
17 | height: 100%;
18 | background-color: @colorBgNavi;
19 |
20 | .applicationName {
21 | margin: 0;
22 | margin-top: 15px;
23 | padding: 10px 15px;
24 | font: bold 1.25em Helvetica;
25 | color: #fff;
26 |
27 | a {
28 | color: #fff;
29 | }
30 | }
31 |
32 | .search {
33 | padding: 10px 15px;
34 |
35 | input {
36 | background-color: #333;
37 | color: #fff;
38 | border-color: #555;
39 | }
40 | }
41 |
42 | .list {
43 | padding: 10px 15px 0 15px;
44 | position: relative;
45 | overflow: auto;
46 | width: 100%;
47 | }
48 |
49 | li.item {
50 | margin-bottom: 8px;
51 | padding-bottom: 8px;
52 | border-bottom: 1px solid #333;
53 |
54 | a {
55 | color: #bbb;
56 | &:hover {
57 | color: #fff;
58 | }
59 | }
60 | .title {
61 | cursor: pointer;
62 | position: relative;
63 | a {
64 | color: #e1e1e1;
65 | &:hover {
66 | color: #fff;
67 | }
68 | }
69 | display: block;
70 | font-size: 0.8em;
71 |
72 | .static {
73 | display: block;
74 | border-radius: 3px;
75 | background-color: @colorSubtitle;
76 | color: #000;
77 | font-size: 0.7em;
78 | padding: 2px 4px;
79 | float: right;
80 | }
81 | }
82 |
83 | .subtitle {
84 | margin-top: 10px;
85 | font: bold 0.65em Helvetica;
86 | color: @colorSubtitle;
87 | display: block;
88 | }
89 |
90 |
91 | ul {
92 | & > li {
93 | font-size: 0.7em;
94 | padding-left: 8px;
95 | margin-top: 2px;
96 | }
97 | }
98 |
99 | .itemMembers {
100 | display: none;
101 | }
102 | }
103 | }
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jaguarjs-jsdoc",
3 | "version": "0.0.1",
4 | "description": "Jaguar.js template for JSDoc 3",
5 | "main": "Gruntfile.js",
6 | "dependencies": {
7 | "taffydb": "^2.7.2",
8 | "underscore": "^1.7.0"
9 | },
10 | "devDependencies": {
11 | "connect-livereload": "~0.3.2",
12 | "grunt": "~0.4.2",
13 | "grunt-contrib-clean": "~0.5.0",
14 | "grunt-contrib-copy": "~0.5.0",
15 | "grunt-contrib-less": "~0.9.0",
16 | "grunt-contrib-uglify": "~0.2.7",
17 | "grunt-contrib-watch": "~0.5.3",
18 | "grunt-jsdoc": "~0.5.1",
19 | "grunt-contrib-connect": "~0.6.0"
20 | },
21 | "scripts": {
22 | "test": "echo \"Error: no test specified\" && exit 1"
23 | },
24 | "repository": {
25 | "type": "git",
26 | "url": "git://github.com/davidshimjs/jaguarjs-jsdoc.git"
27 | },
28 | "keywords": [
29 | "jsdoc",
30 | "jsdoc3",
31 | "jaguar.js",
32 | "template"
33 | ],
34 | "author": "davidshimjs",
35 | "license": "MIT",
36 | "readmeFilename": "README.md",
37 | "bugs": {
38 | "url": "https://github.com/davidshimjs/jaguarjs-jsdoc/issues"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/lib/jaguarjs-jsdoc/static/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/lib/jaguarjs-jsdoc/static/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/lib/jaguarjs-jsdoc/static/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/scripts/linenumber.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var counter = 0;
3 | var numbered;
4 | var source = document.getElementsByClassName('prettyprint source');
5 |
6 | if (source && source[0]) {
7 | var linenums = config.linenums;
8 |
9 | if (linenums) {
10 | source = source[0].getElementsByTagName('ol')[0];
11 |
12 | numbered = Array.prototype.slice.apply(source.children);
13 | numbered = numbered.map(function(item) {
14 | counter++;
15 | item.id = 'line' + counter;
16 | });
17 | } else {
18 | source = source[0].getElementsByTagName('code')[0];
19 |
20 | numbered = source.innerHTML.split('\n');
21 | numbered = numbered.map(function(item) {
22 | counter++;
23 | return '' + item;
24 | });
25 |
26 | source.innerHTML = numbered.join('\n');
27 | }
28 | }
29 | })();
30 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/scripts/main.js:
--------------------------------------------------------------------------------
1 | $(function () {
2 | // Search Items
3 | $('#search').on('keyup', function (e) {
4 | var value = $(this).val();
5 | var $el = $('.navigation');
6 |
7 | if (value) {
8 | var regexp = new RegExp(value, 'i');
9 | $el.find('li, .itemMembers').hide();
10 |
11 | $el.find('li').each(function (i, v) {
12 | var $item = $(v);
13 |
14 | if ($item.data('name') && regexp.test($item.data('name'))) {
15 | $item.show();
16 | $item.closest('.itemMembers').show();
17 | $item.closest('.item').show();
18 | }
19 | });
20 | } else {
21 | $el.find('.item, .itemMembers').show();
22 | }
23 |
24 | $el.find('.list').scrollTop(0);
25 | });
26 |
27 | // Toggle when click an item element
28 | $('.navigation').on('click', '.title', function (e) {
29 | $(this).parent().find('.itemMembers').toggle();
30 | });
31 |
32 | // Show an item related a current documentation automatically
33 | var filename = $('.page-title').data('filename').replace(/\.[a-z]+$/, '');
34 | var $currentItem = $('.navigation .item[data-name*="' + filename + '"]:eq(0)');
35 |
36 | if ($currentItem.length) {
37 | $currentItem
38 | .remove()
39 | .prependTo('.navigation .list')
40 | .show()
41 | .find('.itemMembers')
42 | .show();
43 | }
44 |
45 | // Auto resizing on navigation
46 | var _onResize = function () {
47 | var height = $(window).height();
48 | var $el = $('.navigation');
49 |
50 | $el.height(height).find('.list').height(height - 133);
51 | };
52 |
53 | $(window).on('resize', _onResize);
54 | _onResize();
55 |
56 | // disqus code
57 | if (config.disqus) {
58 | $(window).on('load', function () {
59 | var disqus_shortname = config.disqus; // required: replace example with your forum shortname
60 | var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
61 | dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
62 | (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
63 | var s = document.createElement('script'); s.async = true;
64 | s.type = 'text/javascript';
65 | s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
66 | document.getElementsByTagName('BODY')[0].appendChild(s);
67 | });
68 | }
69 | });
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/scripts/prettify/lang-css.js:
--------------------------------------------------------------------------------
1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com",
2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]);
3 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/styles/prettify-jsdoc.css:
--------------------------------------------------------------------------------
1 | /* JSDoc prettify.js theme */
2 |
3 | /* plain text */
4 | .pln {
5 | color: #000000;
6 | font-weight: normal;
7 | font-style: normal;
8 | }
9 |
10 | /* string content */
11 | .str {
12 | color: #006400;
13 | font-weight: normal;
14 | font-style: normal;
15 | }
16 |
17 | /* a keyword */
18 | .kwd {
19 | color: #000000;
20 | font-weight: bold;
21 | font-style: normal;
22 | }
23 |
24 | /* a comment */
25 | .com {
26 | font-weight: normal;
27 | font-style: italic;
28 | }
29 |
30 | /* a type name */
31 | .typ {
32 | color: #000000;
33 | font-weight: normal;
34 | font-style: normal;
35 | }
36 |
37 | /* a literal value */
38 | .lit {
39 | color: #006400;
40 | font-weight: normal;
41 | font-style: normal;
42 | }
43 |
44 | /* punctuation */
45 | .pun {
46 | color: #000000;
47 | font-weight: bold;
48 | font-style: normal;
49 | }
50 |
51 | /* lisp open bracket */
52 | .opn {
53 | color: #000000;
54 | font-weight: bold;
55 | font-style: normal;
56 | }
57 |
58 | /* lisp close bracket */
59 | .clo {
60 | color: #000000;
61 | font-weight: bold;
62 | font-style: normal;
63 | }
64 |
65 | /* a markup tag name */
66 | .tag {
67 | color: #006400;
68 | font-weight: normal;
69 | font-style: normal;
70 | }
71 |
72 | /* a markup attribute name */
73 | .atn {
74 | color: #006400;
75 | font-weight: normal;
76 | font-style: normal;
77 | }
78 |
79 | /* a markup attribute value */
80 | .atv {
81 | color: #006400;
82 | font-weight: normal;
83 | font-style: normal;
84 | }
85 |
86 | /* a declaration */
87 | .dec {
88 | color: #000000;
89 | font-weight: bold;
90 | font-style: normal;
91 | }
92 |
93 | /* a variable name */
94 | .var {
95 | color: #000000;
96 | font-weight: normal;
97 | font-style: normal;
98 | }
99 |
100 | /* a function name */
101 | .fun {
102 | color: #000000;
103 | font-weight: bold;
104 | font-style: normal;
105 | }
106 |
107 | /* Specify class=linenums on a pre to get line numbering */
108 | ol.linenums {
109 | margin-top: 0;
110 | margin-bottom: 0;
111 | }
112 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/static/styles/prettify-tomorrow.css:
--------------------------------------------------------------------------------
1 | /* Tomorrow Theme */
2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */
3 | /* Pretty printing styles. Used with prettify.js. */
4 | /* SPAN elements with the classes below are added by prettyprint. */
5 | /* plain text */
6 | .pln {
7 | color: #4d4d4c; }
8 |
9 | @media screen {
10 | /* string content */
11 | .str {
12 | color: #718c00; }
13 |
14 | /* a keyword */
15 | .kwd {
16 | color: #8959a8; }
17 |
18 | /* a comment */
19 | .com {
20 | color: #8e908c; }
21 |
22 | /* a type name */
23 | .typ {
24 | color: #4271ae; }
25 |
26 | /* a literal value */
27 | .lit {
28 | color: #f5871f; }
29 |
30 | /* punctuation */
31 | .pun {
32 | color: #4d4d4c; }
33 |
34 | /* lisp open bracket */
35 | .opn {
36 | color: #4d4d4c; }
37 |
38 | /* lisp close bracket */
39 | .clo {
40 | color: #4d4d4c; }
41 |
42 | /* a markup tag name */
43 | .tag {
44 | color: #c82829; }
45 |
46 | /* a markup attribute name */
47 | .atn {
48 | color: #f5871f; }
49 |
50 | /* a markup attribute value */
51 | .atv {
52 | color: #3e999f; }
53 |
54 | /* a declaration */
55 | .dec {
56 | color: #f5871f; }
57 |
58 | /* a variable name */
59 | .var {
60 | color: #c82829; }
61 |
62 | /* a function name */
63 | .fun {
64 | color: #4271ae; } }
65 | /* Use higher contrast and text-weight for printable form. */
66 | @media print, projection {
67 | .str {
68 | color: #060; }
69 |
70 | .kwd {
71 | color: #006;
72 | font-weight: bold; }
73 |
74 | .com {
75 | color: #600;
76 | font-style: italic; }
77 |
78 | .typ {
79 | color: #404;
80 | font-weight: bold; }
81 |
82 | .lit {
83 | color: #044; }
84 |
85 | .pun, .opn, .clo {
86 | color: #440; }
87 |
88 | .tag {
89 | color: #006;
90 | font-weight: bold; }
91 |
92 | .atn {
93 | color: #404; }
94 |
95 | .atv {
96 | color: #060; } }
97 | /* Style */
98 | /*
99 | pre.prettyprint {
100 | background: white;
101 | font-family: Menlo, Monaco, Consolas, monospace;
102 | font-size: 12px;
103 | line-height: 1.5;
104 | border: 1px solid #ccc;
105 | padding: 10px; }
106 | */
107 |
108 | /* Specify class=linenums on a pre to get line numbering */
109 | ol.linenums {
110 | margin-top: 0;
111 | margin-bottom: 0; }
112 |
113 | /* IE indents via margin-left */
114 | li.L0,
115 | li.L1,
116 | li.L2,
117 | li.L3,
118 | li.L4,
119 | li.L5,
120 | li.L6,
121 | li.L7,
122 | li.L8,
123 | li.L9 {
124 | /* */ }
125 |
126 | /* Alternate shading for lines */
127 | li.L1,
128 | li.L3,
129 | li.L5,
130 | li.L7,
131 | li.L9 {
132 | /* */ }
133 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/details.tmpl:
--------------------------------------------------------------------------------
1 |
5 |
6 |
10 |
11 | Properties:
12 |
13 |
14 |
15 |
16 |
17 |
18 | - Version:
19 |
20 |
21 |
22 |
23 | - Since:
24 |
25 |
26 |
27 |
28 | - Deprecated
32 |
33 |
34 |
35 | - Author:
36 | -
37 |
40 |
41 |
42 |
43 |
44 | - Copyright:
45 |
46 |
47 |
48 |
49 | - License:
50 |
51 |
52 |
53 |
54 | - Default Value:
55 |
56 |
57 |
58 |
59 | - Tutorials:
60 | -
61 |
64 |
65 |
66 |
67 |
68 | - See:
69 | -
70 |
73 |
74 |
75 |
76 |
77 | - TODO
78 | -
79 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/example.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/examples.tmpl:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 | ') === -1) { ?>
10 |
11 |
12 | /g, '') ?>
13 |
14 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/exceptions.tmpl:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 | -
7 |
8 |
9 |
10 |
11 | -
12 |
13 | -
14 | Type
15 |
16 | -
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/layout.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
28 |
29 |
30 |
31 |
34 |
35 |
36 |
37 |
48 |
49 |
50 |
51 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/mainpage.tmpl:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/members.tmpl:
--------------------------------------------------------------------------------
1 | ' + self.linkto(name, self.htmlsafe(name)) + ' ';
9 | });
10 | }
11 | ?>
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | Example 1? 's':'' ?>
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/method.tmpl:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | ,
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | Type:
35 |
40 |
41 |
42 |
43 | This:
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | Fires:
55 |
58 |
59 |
60 |
61 | Listens to Events:
62 |
65 |
66 |
67 |
68 | Listeners of This Event:
69 |
72 |
73 |
74 |
75 | Throws:
76 | 1) { ?>
82 |
83 |
85 |
86 |
87 | Returns:
88 |
89 |
90 |
91 |
92 | Example 1? 's':'' ?>
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/navigation.tmpl:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 | -
15 |
16 |
17 |
18 | static
19 |
20 |
21 |
22 |
25 | Members
26 |
29 |
30 |
34 |
35 |
36 |
39 | Typedefs
40 |
43 |
44 |
48 |
49 |
50 |
53 | Methods
54 |
58 |
59 |
63 |
64 |
65 |
68 | Events
69 |
72 |
73 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/params.tmpl:
--------------------------------------------------------------------------------
1 |
40 |
41 |
42 |
43 |
44 |
45 | | Name |
46 |
47 |
48 | Type |
49 |
50 |
51 | Default |
52 |
53 |
54 | Description |
55 |
56 |
57 |
58 |
59 |
64 |
65 |
66 |
67 | |
68 |
69 |
70 |
71 |
72 |
73 |
74 | |
75 |
76 |
77 |
78 |
79 |
80 |
81 | |
82 |
83 |
84 |
85 |
86 |
87 | optional
88 |
89 |
90 | nullable
91 |
92 |
93 |
94 | repeatable
95 |
96 |
97 |
98 |
99 | |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/properties.tmpl:
--------------------------------------------------------------------------------
1 |
40 |
41 |
42 |
43 |
44 |
45 | | Name |
46 |
47 |
48 | Type |
49 |
50 |
51 | Argument |
52 |
53 |
54 |
55 | Default |
56 |
57 |
58 | Description |
59 |
60 |
61 |
62 |
63 |
68 |
69 |
70 |
71 | |
72 |
73 |
74 |
75 |
76 |
77 |
78 | |
79 |
80 |
81 |
82 |
83 | <optional>
84 |
85 |
86 |
87 | <nullable>
88 |
89 | |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | |
98 |
99 |
100 |
101 | Properties
102 | |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/returns.tmpl:
--------------------------------------------------------------------------------
1 | /g, '');
10 |
11 | var isNamed = ret.name ? true : false;
12 | var name = ret.name || ret.description;
13 | var startSpacePos = name.indexOf(' ');
14 |
15 | if (parentReturn !== null && name.indexOf(parentReturn.name + '.') === 0) {
16 | ret.name = isNamed ? name.substr(parentReturn.name.length + 1) : name.substr(parentReturn.name.length + 1, startSpacePos - (parentReturn.name.length + 1));
17 |
18 | if (!isNamed) {
19 | ret.description = ret.description.substr(startSpacePos + 1);
20 | }
21 |
22 | ret.isSubReturns = true;
23 | parentReturn.subReturns = parentReturn.subReturns || [];
24 | parentReturn.subReturns.push(ret);
25 | returns[i] = null;
26 | } else if (returns.length > 1 || ret.isSubReturns) {
27 | if (!isNamed) {
28 | ret.name = ret.description.substr(0, startSpacePos !== -1 ? startSpacePos : ret.description.length);
29 | ret.description = startSpacePos !== -1 ? ret.description.substr(startSpacePos + 1) : '';
30 | }
31 |
32 | parentReturn = ret;
33 | }
34 | }
35 |
36 | if (ret.name) {
37 | hasName = true;
38 | }
39 |
40 | if (ret.type) {
41 | hasType = true;
42 | }
43 | });
44 | ?>
45 |
46 |
47 |
48 |
49 |
50 | | Name |
51 | Type |
52 | Description |
53 |
54 |
55 |
56 |
63 |
64 | |
65 |
66 |
69 |
70 | |
71 |
74 | |
75 |
76 |
77 | |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/source.tmpl:
--------------------------------------------------------------------------------
1 |
4 |
9 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/tutorial.tmpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 0) { ?>
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/lib/jaguarjs-jsdoc/tmpl/type.tmpl:
--------------------------------------------------------------------------------
1 |
5 |
6 | |
7 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ycc.js",
3 | "version": "0.0.7",
4 | "description": "Mini and powerful canvas engine for creating App or Game.",
5 | "main": "./build/ycc.min.js",
6 | "scripts": {
7 | "start": "grunt",
8 | "build": "grunt build",
9 | "build:game_super_mario": "grunt build:game_super_mario",
10 | "doc": "grunt jsdoc",
11 | "clean": "grunt clean",
12 | "min": "grunt uglify",
13 | "concat": "grunt concat",
14 | "release": "grunt release",
15 | "example": "start http://localhost:7777/examples/index.html & http-server -p 7777"
16 | },
17 | "repository": {
18 | "type": "git",
19 | "url": "https://github.com/lizhiqianduan/ycc.git"
20 | },
21 | "author": "xiaohei",
22 | "license": "ISC",
23 | "keywords": [
24 | "ycc.js",
25 | "yccjs",
26 | "ycc",
27 | "ycc-engine",
28 | "engine",
29 | "canvas"
30 | ],
31 | "bugs": {
32 | "url": "https://github.com/lizhiqianduan/ycc/issues"
33 | },
34 | "homepage": "https://github.com/lizhiqianduan/ycc",
35 | "devDependencies": {
36 | "grunt": "^0.4.5",
37 | "grunt-cli": "^1.2.0",
38 | "grunt-contrib-clean": "^1.1.0",
39 | "grunt-contrib-concat": "^1.0.0",
40 | "grunt-contrib-copy": "^1.0.0",
41 | "grunt-contrib-uglify": "^1.0.1",
42 | "grunt-contrib-watch": "^1.0.0",
43 | "grunt-jsdoc": "^2.1.1",
44 | "matter-js": "^0.14.2",
45 | "http-server": "^0.11.1"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/Ycc.Ajax.class.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.Ajax.class.js
3 | * @author xiaohei
4 | * @date 2018/10/31
5 | * @description Ycc.Ajax.class文件
6 | */
7 |
8 |
9 |
10 | (function (Ycc) {
11 |
12 | /**
13 | * 异步加载类
14 | * @constructor
15 | */
16 | Ycc.Ajax = function () {
17 | this.yccClass = Ycc.Ajax;
18 | };
19 |
20 |
21 |
22 | /**
23 | * ajax get请求
24 | * @param url
25 | * @param successCb 成功的回调函数
26 | * @param errorCb 失败的回调函数
27 | * @param responseType
28 | */
29 | /**
30 | * ajax get请求
31 | * @param option
32 | * @param option.url
33 | * @param option.successCb
34 | * @param option.successCb
35 | * @param option.responseType
36 | */
37 | Ycc.Ajax.prototype.get = function (option) {
38 | var self = this;
39 |
40 | var url='',
41 | successCb,
42 | errorCb,
43 | responseType='json';
44 | if(arguments.length===1){
45 | url='';
46 | successCb=option.successCb;
47 | errorCb=option.errorCb;
48 | responseType='json';
49 | }else {
50 | url=arguments[0];
51 | successCb=arguments[1];
52 | errorCb=arguments[2];
53 | responseType=arguments[3];
54 | }
55 |
56 |
57 | var request = new XMLHttpRequest();
58 | request.open('GET', url, true);
59 | request.responseType = responseType;
60 |
61 | // Decode asynchronously
62 | request.onload = function() {
63 | successCb.call(self,request.response);
64 | };
65 |
66 | request.onerror = function (e) {
67 | errorCb.call(self,e);
68 | };
69 | request.send();
70 | };
71 |
72 |
73 |
74 |
75 | })(Ycc);
--------------------------------------------------------------------------------
/src/Ycc.Debugger.class.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.Debugger.class.js
3 | * @author xiaohei
4 | * @date 2018/10/24
5 | * @description Ycc.Debugger.class文件
6 | */
7 |
8 |
9 | (function (Ycc) {
10 |
11 | /**
12 | * ycc的调试模块
13 | * @constructor
14 | */
15 | Ycc.Debugger = function (yccInstance) {
16 | this.yccClass = Ycc.Debugger;
17 |
18 | /**
19 | * ycc的实例
20 | */
21 | this.yccInstance = yccInstance;
22 | /**
23 | * 信息面板显示的UI 帧间隔
24 | * @type {Ycc.UI}
25 | */
26 | this.deltaTime = null;
27 | /**
28 | * 信息面板显示的UI 帧间隔期望值
29 | * @type {Ycc.UI}
30 | */
31 | this.deltaTimeExpect = null;
32 | /**
33 | * 信息面板显示的UI 总帧数
34 | * @type {Ycc.UI}
35 | */
36 | this.frameAllCount = null;
37 | /**
38 | * 信息面板显示的UI 帧间隔平均值
39 | * @type {Ycc.UI}
40 | */
41 | this.deltaTimeAverage = null;
42 |
43 | /**
44 | * 当前帧渲染耗时
45 | * @type {Ycc.UI}
46 | */
47 | this.renderTime = null;
48 |
49 | /**
50 | * 当前帧渲染的所有UI个数
51 | * @type {Ycc.UI}
52 | */
53 | this.renderUiCount = null;
54 |
55 | this.totalJSHeapSize = null;
56 |
57 | this.usedJSHeapSize = null;
58 |
59 | this.jsHeapSizeLimit = null;
60 |
61 |
62 | /**
63 | * 调试面板所显示的字段,示例:[{name,cb,ui}]
64 | * @type {Array}
65 | */
66 | this.fields = [];
67 |
68 | /**
69 | * 调试面板的容纳区
70 | * @type {Ycc.UI.Rect}
71 | */
72 | this.rect = null;
73 |
74 | /**
75 | * 调试面板的图层
76 | */
77 | this.layer = null;
78 |
79 | };
80 |
81 |
82 | Ycc.Debugger.prototype.init = function () {
83 | this.rect = new Ycc.UI.Rect({
84 | name:'debuggerRect',
85 | rect:new Ycc.Math.Rect(10,10,200,140),
86 | color:'rgba(255,255,0,0.5)'
87 | });
88 | this.layer = yccInstance.layerManager.newLayer({
89 | name:"debug图层"
90 | });
91 | var self = this;
92 | this.yccInstance.ticker.addFrameListener(function () {
93 | self.updateInfo();
94 | });
95 | };
96 |
97 | /**
98 | * 显示调试面板
99 | */
100 | Ycc.Debugger.prototype.showDebugPanel = function () {
101 | this.init();
102 | var layer = this.layer;
103 | if(layer.uiList.indexOf(this.rect)===-1)
104 | layer.addUI(this.rect);
105 | };
106 |
107 |
108 |
109 | /**
110 | * 更新面板的调试信息
111 | */
112 | Ycc.Debugger.prototype.updateInfo = function () {
113 |
114 | // 强制使debug面板置顶
115 | var layerList = this.yccInstance.layerList;
116 | var index = layerList.indexOf(this.layer);
117 | // bug 调试layer必须存在
118 | if(index===-1) return;
119 | if(index+1!==layerList.length){
120 | layerList.splice(index,1);
121 | layerList.push(this.layer);
122 | }
123 |
124 | this.rect.rect.height = this.fields.length*20;
125 | this.fields.forEach(function (field) {
126 | field.ui.content = field.name+' '+field.cb();
127 | });
128 |
129 | };
130 |
131 |
132 | /**
133 | * 添加一个信息项
134 | * @param name
135 | * @param cb() {function}
136 | * cb必须返回一个值,这个值将直接填入
137 | *
138 | */
139 | Ycc.Debugger.prototype.addField = function (name, cb) {
140 | var index = this.fields.length;
141 | var ui = new Ycc.UI.SingleLineText({
142 | content:"usedJSHeapSize "+cb(),
143 | fontSize:'12px',
144 | rect:new Ycc.Math.Rect(0,20*index,100,20),
145 | color:'green'
146 | });
147 | this.fields.push({name:name,cb:cb,ui:ui});
148 | this.rect.addChild(ui);
149 | };
150 |
151 |
152 | /**
153 | * 将调试面板添加至某个图层
154 | * @param layer {Ycc.Layer}
155 | */
156 | Ycc.Debugger.prototype.addToLayer = function (layer) {
157 | if(layer.uiList.indexOf(this.rect)===-1)
158 | layer.addUI(this.rect);
159 | };
160 |
161 | /**
162 | * 更新某个调试字段的回调函数
163 | * @param name
164 | * @param cb
165 | */
166 | Ycc.Debugger.prototype.updateField = function (name,cb) {
167 | for(var i=0;i=start.x && x<=end.x) {
43 | crossNum++;
44 | continue;
45 | }
46 | var k=(end.y-start.y)/(end.x-start.x);
47 | var x0 = (y-start.y)/k+start.x;
48 | if(x0>=start.x && x0<=end.x) crossNum++;
49 | }
50 | return crossNum/2===1;
51 | };
52 |
53 |
54 | })(Ycc);
--------------------------------------------------------------------------------
/src/Ycc.PhotoManager.class.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.PhotoManager.class.js
3 | * @author xiaohei
4 | * @date 2017/9/30
5 | * @description Ycc.PhotoManager.class文件。
6 | * Ycc实例的快照管理类
7 | *
8 | */
9 |
10 |
11 |
12 | (function (Ycc){
13 | /**
14 | * 照片数据结构类
15 | * @param imageData
16 | * @constructor
17 | */
18 | var Photo = function(imageData) {
19 | this.imageData = imageData;
20 | this.createTime = new Date();
21 | this.id = this.createTime.getTime();
22 | };
23 |
24 |
25 | /**
26 | * Ycc实例的快照管理类
27 | * @param yccInstance {Ycc}
28 | * @constructor
29 | */
30 | Ycc.PhotoManager = function (yccInstance) {
31 |
32 | this.yccInstance = yccInstance;
33 |
34 | this.ctx = yccInstance.ctx;
35 |
36 | this._photos = [];
37 | };
38 |
39 | /**
40 | * 保存快照,即保存当前的原子图形渲染步骤
41 | */
42 | Ycc.PhotoManager.prototype.takePhoto = function () {
43 | this._photos.push(new Photo(this.ctx.getImageData(0,0,this.yccInstance.getStageWidth(),this.yccInstance.getStageHeight())));
44 | return this;
45 | };
46 |
47 | /**
48 | * 获取保存的历史照片
49 | * @returns {Array}
50 | */
51 | Ycc.PhotoManager.prototype.getHistoryPhotos = function () {
52 | return this._photos;
53 | };
54 | /**
55 | * 显示照片
56 | * @param photo {Photo}
57 | * @returns {Photo}
58 | */
59 | Ycc.PhotoManager.prototype.showPhoto = function (photo) {
60 | this.ctx.putImageData(photo.imageData,0,0);
61 | return photo;
62 | };
63 |
64 |
65 | /**
66 | * 显示最后一次保存的快照
67 | * @returns {boolean}
68 | */
69 | Ycc.PhotoManager.prototype.showLastPhoto = function () {
70 | var len = this._photos.length;
71 | var photo = false;
72 | if(len>=1){
73 | photo = this._photos[len-1];
74 | this.showPhoto(photo);
75 | }
76 | return photo;
77 | };
78 |
79 | /**
80 | * 删除照片
81 | * @param photoId 照片的id
82 | * @returns {*}
83 | */
84 | Ycc.PhotoManager.prototype.delPhotoById = function (photoId) {
85 | var tempPhotos = this._photos.slice(0);
86 | for(var i=0;i 计算与绘制分离的好处是,在绘制UI之前就可以提前确定元素的各种信息,从而判断是否需要绘制。
41 | * @override
42 | */
43 | Ycc.UI.Circle.prototype.computeUIProps = function () {
44 | if(!this.point) return new Ycc.Debugger.Error('Circle need prop point');
45 |
46 | var x=this.point.x,
47 | y=this.point.y,
48 | r=this.r;
49 | this.rect = new Ycc.Math.Rect(x-r,y-r,2*r,2*r);
50 | // 计算多边形坐标
51 | this.coordinates= this.rect.getVertices();
52 | // 计算相对位置
53 | this.x=this.point.x,this.y=this.point.y;
54 |
55 | };
56 |
57 |
58 | /**
59 | * 绘制
60 | * @override
61 | */
62 | Ycc.UI.Circle.prototype.render = function () {
63 | var ctx = this.ctxCache;
64 |
65 | var point = this.transformByRotate(this.point);
66 |
67 |
68 | ctx.save();
69 | ctx.beginPath();
70 | ctx.fillStyle = this.color;
71 | ctx.strokeStyle = this.color;
72 |
73 | ctx.arc(
74 | point.x*this.dpi,
75 | point.y*this.dpi,
76 | this.r*this.dpi,
77 | 0,
78 | 2*Math.PI
79 | );
80 |
81 | ctx.closePath();
82 | if(!this.fill)
83 | ctx.stroke();
84 | else
85 | ctx.fill();
86 | ctx.restore();
87 | };
88 |
89 | /**
90 | * 绘制旋转缩放之前的UI
91 | * @override
92 | */
93 | Ycc.UI.Circle.prototype.renderDashBeforeUI = function (ctx) {
94 | if(!this.isShowRotateBeforeUI || this.coordinates.length===0) return;
95 | var self = this;
96 | ctx = this.ctx;
97 | var pa = this.getParent();
98 | var point = pa?pa.transformToAbsolute(this.point):this.point;
99 |
100 | ctx.save();
101 | // 虚线
102 | ctx.setLineDash([10]);
103 | ctx.beginPath();
104 | this.ctx.arc(
105 | point.x,
106 | point.y,
107 | this.r,
108 | 0,
109 | 2*Math.PI
110 | );
111 | ctx.closePath();
112 | ctx.strokeStyle = this.color;
113 | ctx.stroke();
114 | ctx.restore();
115 | };
116 |
117 |
118 | /**
119 | * 判断是否在圆内
120 | * @param dot 绝对坐标
121 | * @param noneZeroMode
122 | * @override
123 | */
124 | Ycc.UI.Circle.prototype.containDot = function (dot,noneZeroMode) {
125 | var point = this.transformByRotate(this.point);
126 | return Math.pow(dot.x-point.x,2)+Math.pow(dot.y-point.y,2)<=Math.pow(this.r,2);
127 | };
128 |
129 |
130 | })(Ycc);
--------------------------------------------------------------------------------
/src/Ycc.UI.ComponentButton.class.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.UI.ComponentButton.class.js
3 | * @author xiaohei
4 | * @date 2018/11/27
5 | * @description Ycc.UI.ComponentButton.class文件
6 | */
7 |
8 | (function (Ycc) {
9 |
10 | /**
11 | * 按钮组件
12 | * 组件自身也是一个UI,所以option包含ui.base的所有属性
13 | * @param option {Object}
14 | * @param option.rect {Ycc.Math.Rect} 相对于父级按钮的位置,继承于base
15 | * @param option.rectBgColor {String} 按钮区域的背景色,继承于base
16 | * @param option.rectBorderWidth {Number} 按钮区域的边框宽度,继承于base
17 | * @param option.rectBorderColor {String} 按钮区域的边框颜色,继承于base
18 | * @param option.backgroundImageRes {String} 按钮区域的图片资源
19 | * @param option.text {String} 按钮内的文字
20 | * @param option.textColor {String} 按钮内的文字的颜色
21 | * @constructor
22 | */
23 | Ycc.UI.ComponentButton = function ComponentButton(option) {
24 | Ycc.UI.Base.call(this,option);
25 | this.yccClass = Ycc.UI.ComponentButton;
26 |
27 | /**
28 | * 容纳区的边框宽度
29 | * @type {number}
30 | */
31 | this.rectBorderWidth = 1;
32 |
33 | /**
34 | * 容纳区边框颜色
35 | * @type {string}
36 | */
37 | this.rectBorderColor = "#000";
38 |
39 | /**
40 | * 背景图资源
41 | * @type {null}
42 | */
43 | this.backgroundImageRes = null;
44 |
45 | /**
46 | * 按钮内的文字
47 | * @type {string}
48 | */
49 | this.text = "";
50 |
51 | /**
52 | * 按钮文字颜色
53 | * @type {string}
54 | */
55 | this.textColor = "black";
56 |
57 | /**
58 | * 背景
59 | * @type {null}
60 | * @private
61 | */
62 | this.__bgUI = null;
63 |
64 | /**
65 | * 文字
66 | * @type {null}
67 | * @private
68 | */
69 | this.__textUI = null;
70 |
71 | this.extend(option);
72 |
73 | this.__componentInit();
74 | };
75 | // 继承prototype
76 | Ycc.utils.mergeObject(Ycc.UI.ComponentButton.prototype,Ycc.UI.Base.prototype);
77 | Ycc.UI.ComponentButton.prototype.constructor = Ycc.UI.ComponentButton;
78 |
79 |
80 | /**
81 | * 组件初始化
82 | * @private
83 | */
84 | Ycc.UI.ComponentButton.prototype.__componentInit = function () {
85 |
86 | if(this.backgroundImageRes){
87 | this.__bgUI = new Ycc.UI.Image({
88 | rect:new Ycc.Math.Rect(0,0,this.rect.width,this.rect.height),
89 | fillMode:'scale',
90 | res:this.backgroundImageRes,
91 | stopEventBubbleUp:false
92 | });
93 | this.addChild(this.__bgUI);
94 | }
95 | if(this.text!==""){
96 | this.__textUI = new Ycc.UI.SingleLineText({
97 | rect:new Ycc.Math.Rect(0,0,this.rect.width,this.rect.height),
98 | content:this.text,
99 | color:this.textColor,
100 | xAlign:'center',
101 | stopEventBubbleUp:false
102 | });
103 | this.addChild(this.__textUI);
104 | }
105 | };
106 |
107 |
108 | /**
109 | * 更新属性
110 | */
111 | Ycc.UI.Base.prototype.computeUIProps = function () {
112 | if(this.__bgUI){
113 | this.__bgUI.rect.width = this.rect.width;
114 | this.__bgUI.rect.height = this.rect.height;
115 | this.__bgUI.res = this.backgroundImageRes;
116 | }
117 | if(this.__textUI){
118 | this.__textUI.rect.width = this.rect.width;
119 | this.__textUI.rect.height = this.rect.height;
120 | this.__textUI.content = this.text;
121 | this.__textUI.color = this.textColor;
122 | }
123 | };
124 | })(Ycc);
--------------------------------------------------------------------------------
/src/Ycc.UI.Line.class.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.UI.Line.class.js
3 | * @author xiaohei
4 | * @date 2017/11/17
5 | * @description Ycc.UI.Line.class文件
6 | */
7 |
8 |
9 | (function (Ycc) {
10 |
11 | /**
12 | * 线段。可设置属性如下
13 | * @param option {object} 所有可配置的配置项
14 | * @param option.start {Ycc.Math.Dot} 起点
15 | * @param option.end {Ycc.Math.Dot} 终点
16 | * @param option.width=1 {number} 线条宽度
17 | * @param option.color="black" {string} 线条颜色
18 | * @constructor
19 | * @extends Ycc.UI.Polygon
20 | */
21 | Ycc.UI.Line = function Line(option) {
22 | Ycc.UI.Polygon.call(this,option);
23 | this.yccClass = Ycc.UI.Line;
24 |
25 | this.start = new Ycc.Math.Dot(0,0);
26 | this.end = new Ycc.Math.Dot(0,0);
27 | this.width = 1;
28 | this.color = "black";
29 |
30 | this.extend(option);
31 | };
32 | // 继承prototype
33 | Ycc.utils.mergeObject(Ycc.UI.Line.prototype,Ycc.UI.Polygon.prototype);
34 | Ycc.UI.Line.prototype.constructor = Ycc.UI.Line;
35 |
36 | /**
37 | * 计算UI的各种属性。此操作必须在绘制之前调用。
38 | *
计算与绘制分离的好处是,在绘制UI之前就可以提前确定元素的各种信息,从而判断是否需要绘制。
39 | * @override
40 | */
41 | Ycc.UI.Line.prototype.computeUIProps = function () {
42 | this.rect.x = this.start.x 计算与绘制分离的好处是,在绘制UI之前就可以提前确定元素的各种信息,从而判断是否需要绘制。
45 | * @override
46 | */
47 | Ycc.UI.Rect.prototype.computeUIProps = function () {
48 | // 计算多边形坐标
49 | this.coordinates = this.rect.getVertices();
50 | // 赋值位置信息
51 | this.x = this.rect.x,this.y=this.rect.y;
52 |
53 | // this._setCtxProps(this);
54 | };
55 |
56 |
57 | /**
58 | * 绘制
59 | */
60 | Ycc.UI.Rect.prototype.render = function (ctx) {
61 | var self = this;
62 | ctx = ctx || self.ctxCache;
63 | if(!ctx){
64 | console.error("[Ycc error]:","ctx is null !");
65 | return;
66 | }
67 |
68 |
69 | ctx.save();
70 | ctx.fillStyle = this.color;
71 | ctx.strokeStyle = this.color;
72 | this.renderPath(ctx);
73 | this.fill?ctx.fill():ctx.stroke();
74 | ctx.restore();
75 | };
76 |
77 |
78 |
79 |
80 | })(Ycc);
--------------------------------------------------------------------------------
/src/Ycc.polyfill.export.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.polyfill.export.js
3 | * @author xiaohei
4 | * @date 2018/12/11
5 | * @description Ycc.polyfill.export文件
6 | *
7 | * 导出兼容文件,兼容npm模块的加载模式
8 | */
9 |
10 |
11 | ;if(typeof exports==="object"&&typeof module!=="undefined"){
12 | module.exports=Ycc;
13 | }else if(typeof define==="function"){
14 | define("Ycc",Ycc)
15 | }else{
16 | var g;
17 | if(typeof window!=="undefined"){g=window}
18 | else if(typeof global!=="undefined"){g=global}
19 | else if(typeof self!=="undefined"){g=self}
20 | else{g=this}
21 | g.Ycc = Ycc;
22 | }
--------------------------------------------------------------------------------
/src/Ycc.polyfill.wx.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @file Ycc.polyfill.wx.js
3 | * @author xiaohei
4 | * @date 2018/11/19
5 | * @description Ycc.polyfill.wx文件
6 | */
7 |
8 |
9 | // 兼容微信
10 | if("undefined"!== typeof wx){
11 | // Ycc.prototype.getStageWidth = function () {
12 | //
13 | // };
14 |
15 | /*Ycc.Gesture.prototype._init = function () {
16 | console.log('wx gesture init');
17 | };*/
18 |
19 | Ycc.utils.isMobile = function () {
20 | console.log('wx isMobile');
21 | return true;
22 | };
23 |
24 | if("undefined"!== typeof performance){
25 | performance.now = function () {
26 | return Date.now();
27 | };
28 | }
29 | };
--------------------------------------------------------------------------------
/test/bg01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codemyhappy/ycc/9f832abe58f4b4b17d0784baba7408c595b36e61/test/bg01.jpg
--------------------------------------------------------------------------------
/test/matterjs-01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | matterjs 01
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
50 |
--------------------------------------------------------------------------------
/test/memory.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 内存测试
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
39 |
40 |
41 |
77 |
78 |
79 |
113 |
114 |
115 |
137 |
138 |
139 |
140 |
--------------------------------------------------------------------------------
/test/ycc-memory.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ycc的内存测试
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------