mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-09 23:25:23 +00:00
初始化
This commit is contained in:
103
cocos2d-x/templates/js-template-link/src/app.js
Executable file
103
cocos2d-x/templates/js-template-link/src/app.js
Executable file
@@ -0,0 +1,103 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
var HelloWorldLayer = cc.Layer.extend({
|
||||
sprite:null,
|
||||
ctor:function () {
|
||||
//////////////////////////////
|
||||
// 1. super init first
|
||||
this._super();
|
||||
|
||||
/////////////////////////////
|
||||
// 2. add a menu item with "X" image, which is clicked to quit the program
|
||||
// you may modify it.
|
||||
// ask the window size
|
||||
var size = cc.winSize;
|
||||
|
||||
// add a "close" icon to exit the progress. it's an autorelease object
|
||||
var closeItem = new cc.MenuItemImage(
|
||||
res.CloseNormal_png,
|
||||
res.CloseSelected_png,
|
||||
function () {
|
||||
cc.log("Menu is clicked!");
|
||||
}, this);
|
||||
closeItem.attr({
|
||||
x: size.width - 20,
|
||||
y: 20,
|
||||
anchorX: 0.5,
|
||||
anchorY: 0.5
|
||||
});
|
||||
|
||||
var menu = new cc.Menu(closeItem);
|
||||
menu.x = 0;
|
||||
menu.y = 0;
|
||||
this.addChild(menu, 1);
|
||||
|
||||
/////////////////////////////
|
||||
// 3. add your codes below...
|
||||
// add a label shows "Hello World"
|
||||
// create and initialize a label
|
||||
var helloLabel = new cc.LabelTTF("Hello World", "Arial", 38);
|
||||
// position the label on the center of the screen
|
||||
helloLabel.x = size.width / 2;
|
||||
helloLabel.y = 0;
|
||||
// add the label as a child to this layer
|
||||
this.addChild(helloLabel, 5);
|
||||
|
||||
// add "HelloWorld" splash screen"
|
||||
this.sprite = new cc.Sprite(res.HelloWorld_png);
|
||||
this.sprite.attr({
|
||||
x: size.width / 2,
|
||||
y: size.height / 2,
|
||||
scale: 0.5,
|
||||
rotation: 180
|
||||
});
|
||||
this.addChild(this.sprite, 0);
|
||||
|
||||
this.sprite.runAction(
|
||||
cc.sequence(
|
||||
cc.rotateTo(2, 0),
|
||||
cc.scaleTo(2, 1, 1)
|
||||
)
|
||||
);
|
||||
helloLabel.runAction(
|
||||
cc.spawn(
|
||||
cc.moveBy(2.5, cc.p(0, size.height - 40)),
|
||||
cc.tintTo(2.5,255,125,0)
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
var HelloWorldScene = cc.Scene.extend({
|
||||
onEnter:function () {
|
||||
this._super();
|
||||
var layer = new HelloWorldLayer();
|
||||
this.addChild(layer);
|
||||
}
|
||||
});
|
||||
|
35
cocos2d-x/templates/js-template-link/src/resource.js
Executable file
35
cocos2d-x/templates/js-template-link/src/resource.js
Executable file
@@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
var res = {
|
||||
HelloWorld_png : "res/HelloWorld.png",
|
||||
CloseNormal_png : "res/CloseNormal.png",
|
||||
CloseSelected_png : "res/CloseSelected.png"
|
||||
};
|
||||
|
||||
var g_resources = [];
|
||||
for (var i in res) {
|
||||
g_resources.push(res[i]);
|
||||
}
|
Reference in New Issue
Block a user