mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-09 16:46:42 +00:00
初始化
This commit is contained in:
@@ -0,0 +1 @@
|
||||
var mng = new cc.ActionManager();
|
2
engine/docs/cocos2d/core/CCScheduler/schedule.js
Normal file
2
engine/docs/cocos2d/core/CCScheduler/schedule.js
Normal file
@@ -0,0 +1,2 @@
|
||||
//register a schedule to scheduler
|
||||
cc.director.getScheduler().schedule(callback, this, interval, !this._isRunning);
|
@@ -0,0 +1,3 @@
|
||||
//register a schedule to scheduler
|
||||
var scheduler = cc.director.getScheduler();
|
||||
scheduler.scheduleCallbackForTarget(this, function, interval, repeat, delay, !this._isRunning);
|
@@ -0,0 +1,3 @@
|
||||
//register this object to scheduler
|
||||
var scheduler = cc.director.getScheduler();
|
||||
scheduler.scheduleUpdateForTarget(this, priority, !this._isRunning );
|
@@ -0,0 +1,3 @@
|
||||
//unschedule a callback of target
|
||||
var scheduler = cc.director.getScheduler();
|
||||
scheduler.unscheduleCallbackForTarget(this, callback);
|
@@ -0,0 +1,3 @@
|
||||
//unschedules the "update" method.
|
||||
var scheduler = cc.director.getScheduler();
|
||||
scheduler.unscheduleUpdateForTarget(this);
|
58
engine/docs/cocos2d/core/animation-clip/curve-data.js
Normal file
58
engine/docs/cocos2d/core/animation-clip/curve-data.js
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
// 根节点不用查找路径
|
||||
// root properties
|
||||
props: {
|
||||
x: [
|
||||
{ frame: 0, value: 0, curve: [0,0.5,0.5,1] },
|
||||
{ frame: 1, value: 200, curve: null }
|
||||
]
|
||||
},
|
||||
comps: {
|
||||
// component
|
||||
'comp-1': {
|
||||
// component properties
|
||||
'prop-1': [
|
||||
{ frame: 0, value: 10, curve: [0,0.5,0.5,1] },
|
||||
{ frame: 1, value: 20, curve: null }
|
||||
]
|
||||
}
|
||||
},
|
||||
paths: {
|
||||
// key 为节点到root的路径名, 通过cc.find找到
|
||||
'foo/bar': {
|
||||
// node properties
|
||||
props: {
|
||||
x: [
|
||||
{ frame: 0, value: 0, curve: [0,0.5,0.5,1]
|
||||
{ frame: 1, value: 200, curve: null }
|
||||
]
|
||||
},
|
||||
comps: {
|
||||
// component
|
||||
'comp-1': {
|
||||
// component property
|
||||
'prop-1': [
|
||||
{ frame: 0, value: 10, curve: [0,0.5,0.
|
||||
{ frame: 1, value: 20, curve: null }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
'hello': {
|
||||
props: {
|
||||
position: [
|
||||
{
|
||||
frame: 0,
|
||||
value: [0,0],
|
||||
motionPath: [
|
||||
[320, 240, 0, 240, 640, 240],
|
||||
[640, 0, 400, 0, 1000, 0]
|
||||
]
|
||||
},
|
||||
{ frame: 5, value: [640, 480] }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
engine/docs/cocos2d/core/animation-clip/event-data.js
Normal file
11
engine/docs/cocos2d/core/animation-clip/event-data.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// frame : The exactly time in second.
|
||||
// func : Callback function name
|
||||
// params : Callback parameters
|
||||
[
|
||||
{ frame: 0, func: 'onAnimationEvent1', params:['param-1', 'param-2'] },
|
||||
{ frame: 2, func: 'onAnimationEvent3', params:['param-1', 'param-2'] },
|
||||
{ frame: 3, func: 'onAnimationEvent2', params:['param-1'] },
|
||||
// The second event at frame 3
|
||||
{ frame: 3, func: 'onAnimationEvent4', params:['param-1'] },
|
||||
{ frame: 4, func: 'onAnimationEvent4', params:['param-1'] }
|
||||
]
|
@@ -0,0 +1,3 @@
|
||||
---------
|
||||
var sprite = new _ccsg.Sprite();
|
||||
sprite.initWithSpriteFrameName("grossini_dance_01.png");
|
@@ -0,0 +1,18 @@
|
||||
// Create KEYBOARD EventListener.
|
||||
cc.EventListener.create({
|
||||
event: cc.EventListener.KEYBOARD,
|
||||
onKeyPressed: function (keyCode, event) {
|
||||
cc.log('pressed key: ' + keyCode);
|
||||
},
|
||||
onKeyReleased: function (keyCode, event) {
|
||||
cc.log('released key: ' + keyCode);
|
||||
}
|
||||
});
|
||||
|
||||
// Create ACCELERATION EventListener.
|
||||
cc.EventListener.create({
|
||||
event: cc.EventListener.ACCELERATION,
|
||||
callback: function (acc, event) {
|
||||
cc.log('acc: ' + keyCode);
|
||||
}
|
||||
});
|
@@ -0,0 +1,20 @@
|
||||
// Add KEYBOARD EventListener To StatusLabel.
|
||||
cc.eventManager.addListener({
|
||||
event: cc.EventListener.KEYBOARD,
|
||||
onKeyPressed: function(keyCode, event){
|
||||
var label = event.getCurrentTarget();
|
||||
label.setString("Key " + keyCode.toString() + " was pressed!");
|
||||
},
|
||||
onKeyReleased: function(keyCode, event){
|
||||
var label = event.getCurrentTarget();
|
||||
label.setString("Key " + keyCode.toString() + " was released!");
|
||||
}
|
||||
}, statusLabel);
|
||||
|
||||
// Create ACCELERATION EventListener To Sprite.
|
||||
cc.eventManager.addListener({
|
||||
event: cc.EventListener.ACCELERATION,
|
||||
callback: function(acc, event){
|
||||
//Here processing logic.
|
||||
}
|
||||
}, sprite);
|
@@ -0,0 +1,22 @@
|
||||
|
||||
// 1. remove eventManager add Listener;
|
||||
var mouseListener1 = cc.eventManager.addListener({
|
||||
event: cc.EventListener.MOUSE,
|
||||
onMouseDown: function(keyCode, event){ },
|
||||
onMouseUp: function(keyCode, event){ },
|
||||
onMouseMove: function () { },
|
||||
onMouseScroll: function () { }
|
||||
}, node);
|
||||
|
||||
cc.eventManager.removeListener(mouseListener1);
|
||||
|
||||
// 2. remove eventListener create Listener;
|
||||
var mouseListener2 = cc.EventListener.create({
|
||||
event: cc.EventListener.MOUSE,
|
||||
onMouseDown: function(keyCode, event){ },
|
||||
onMouseUp: function(keyCode, event){ },
|
||||
onMouseMove: function () { },
|
||||
onMouseScroll: function () { }
|
||||
});
|
||||
|
||||
cc.eventManager.removeListener(mouseListener2);
|
8
engine/docs/cocos2d/core/event/_getCapturingTargets.js
Normal file
8
engine/docs/cocos2d/core/event/_getCapturingTargets.js
Normal file
@@ -0,0 +1,8 @@
|
||||
----------
|
||||
Subclasses can override this method to make event propagable
|
||||
```js
|
||||
for (var target = this._parent; target; target = target._parent) {
|
||||
if (target._capturingListeners && target._capturingListeners.hasEventListener(type)) {
|
||||
array.push(target);
|
||||
}
|
||||
}
|
18
engine/docs/cocos2d/core/platform/CCCommon/KEY.js
Normal file
18
engine/docs/cocos2d/core/platform/CCCommon/KEY.js
Normal file
@@ -0,0 +1,18 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
onLoad: function () {
|
||||
cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
|
||||
},
|
||||
|
||||
destroy () {
|
||||
cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
|
||||
},
|
||||
|
||||
onKeyDown: function (event) {
|
||||
switch(event.keyCode) {
|
||||
case cc.macro.KEY['0']:
|
||||
console.log('Press a key');
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
46
engine/docs/cocos2d/core/platform/CCEnum/Enum.js
Normal file
46
engine/docs/cocos2d/core/platform/CCEnum/Enum.js
Normal file
@@ -0,0 +1,46 @@
|
||||
// JavaScript:
|
||||
|
||||
var WrapMode = cc.Enum({
|
||||
Repeat: -1,
|
||||
Clamp: -1
|
||||
});
|
||||
|
||||
// Texture.WrapMode.Repeat == 0
|
||||
// Texture.WrapMode.Clamp == 1
|
||||
// Texture.WrapMode[0] == "Repeat"
|
||||
// Texture.WrapMode[1] == "Clamp"
|
||||
|
||||
var FlagType = cc.Enum({
|
||||
Flag1: 1,
|
||||
Flag2: 2,
|
||||
Flag3: 4,
|
||||
Flag4: 8,
|
||||
});
|
||||
|
||||
var AtlasSizeList = cc.Enum({
|
||||
128: 128,
|
||||
256: 256,
|
||||
512: 512,
|
||||
1024: 1024,
|
||||
});
|
||||
|
||||
// TypeScript:
|
||||
|
||||
// If used in TypeScript, just define a TypeScript enum:
|
||||
enum Direction {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
// If you need to inspect the enum in Properties panel, you can call cc.Enum:
|
||||
const {ccclass, property} = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
class NewScript extends cc.Component {
|
||||
@property({
|
||||
type: cc.Enum(Direction) // call cc.Enum
|
||||
})
|
||||
direction: Direction = Direction.Up;
|
||||
}
|
4
engine/docs/cocos2d/core/platform/CCMacro/lerp.js
Normal file
4
engine/docs/cocos2d/core/platform/CCMacro/lerp.js
Normal file
@@ -0,0 +1,4 @@
|
||||
----
|
||||
lerp
|
||||
cc.misc.lerp(2,10,0.5)//returns 6
|
||||
cc.misc.lerp(2,10,0.2)//returns 3.6
|
10
engine/docs/cocos2d/core/platform/attribute/attr.js
Normal file
10
engine/docs/cocos2d/core/platform/attribute/attr.js
Normal file
@@ -0,0 +1,10 @@
|
||||
-----
|
||||
var myClass = function () { this.value = 0.5 };
|
||||
cc.Class.attr(myClass, 'value'); // return undefined
|
||||
cc.Class.attr(myClass, 'value', {}).min = 0; // assign new attribute table
|
||||
//associated with 'value', and set its min = 0
|
||||
cc.Class.attr(myClass, 'value', { // set values max and default
|
||||
max: 1,
|
||||
default: 0.5,
|
||||
});
|
||||
cc.Class.attr(myClass, 'value'); // return { default: 0.5, min: 0, max: 1 }
|
4
engine/docs/cocos2d/core/sprites/addSpriteFrames.js
Normal file
4
engine/docs/cocos2d/core/sprites/addSpriteFrames.js
Normal file
@@ -0,0 +1,4 @@
|
||||
----------------------------------------------------
|
||||
// add SpriteFrames to SpriteFrameCache With File
|
||||
cc.spriteFrameCache.addSpriteFrames(s_grossiniPlist);
|
||||
cc.spriteFrameCache.addSpriteFrames(s_grossiniJson);
|
3
engine/docs/cocos2d/core/sprites/getSpriteFrame.js
Normal file
3
engine/docs/cocos2d/core/sprites/getSpriteFrame.js
Normal file
@@ -0,0 +1,3 @@
|
||||
----------------------------------------------------
|
||||
//get a SpriteFrame by name
|
||||
var frame = cc.spriteFrameCache.getSpriteFrame("grossini_dance_01.png");
|
7
engine/docs/cocos2d/core/textures/TextureAtlas.js
Normal file
7
engine/docs/cocos2d/core/textures/TextureAtlas.js
Normal file
@@ -0,0 +1,7 @@
|
||||
--------------------------
|
||||
1. //creates a TextureAtlas with filename
|
||||
var textureAtlas = new cc.TextureAtlas("res/hello.png", 3);
|
||||
|
||||
2. //creates a TextureAtlas with texture
|
||||
var texture = cc.textureCache.addImage("hello.png");
|
||||
var textureAtlas = new cc.TextureAtlas(texture, 3);
|
2
engine/docs/cocos2d/core/textures/addImage.js
Normal file
2
engine/docs/cocos2d/core/textures/addImage.js
Normal file
@@ -0,0 +1,2 @@
|
||||
----
|
||||
cc.textureCache.addImage("hello.png");
|
2
engine/docs/cocos2d/core/textures/getKeyByTexture.js
Normal file
2
engine/docs/cocos2d/core/textures/getKeyByTexture.js
Normal file
@@ -0,0 +1,2 @@
|
||||
---------
|
||||
var key = cc.textureCache.getKeyByTexture(texture);
|
2
engine/docs/cocos2d/core/textures/getTextureColors.js
Normal file
2
engine/docs/cocos2d/core/textures/getTextureColors.js
Normal file
@@ -0,0 +1,2 @@
|
||||
---------------
|
||||
var cacheTextureForColor = cc.textureCache.getTextureColors(texture);
|
2
engine/docs/cocos2d/core/textures/getTextureForKey.js
Normal file
2
engine/docs/cocos2d/core/textures/getTextureForKey.js
Normal file
@@ -0,0 +1,2 @@
|
||||
------------------
|
||||
var key = cc.textureCache.getTextureForKey("hello.png");
|
3
engine/docs/cocos2d/core/textures/initWithFile.js
Normal file
3
engine/docs/cocos2d/core/textures/initWithFile.js
Normal file
@@ -0,0 +1,3 @@
|
||||
--------------------------------------------------
|
||||
var textureAtlas = new cc.TextureAtlas();
|
||||
textureAtlas.initWithTexture("hello.png", 3);
|
4
engine/docs/cocos2d/core/textures/initWithTexture.js
Normal file
4
engine/docs/cocos2d/core/textures/initWithTexture.js
Normal file
@@ -0,0 +1,4 @@
|
||||
---------------------------
|
||||
var texture = cc.textureCache.addImage("hello.png");
|
||||
var textureAtlas = new cc.TextureAtlas();
|
||||
textureAtlas.initWithTexture(texture, 3);
|
2
engine/docs/cocos2d/core/textures/removeAllTextures.js
Normal file
2
engine/docs/cocos2d/core/textures/removeAllTextures.js
Normal file
@@ -0,0 +1,2 @@
|
||||
--------
|
||||
cc.textureCache.removeAllTextures();
|
2
engine/docs/cocos2d/core/textures/removeTexture.js
Normal file
2
engine/docs/cocos2d/core/textures/removeTexture.js
Normal file
@@ -0,0 +1,2 @@
|
||||
-----
|
||||
cc.textureCache.removeTexture(texture);
|
2
engine/docs/cocos2d/core/textures/removeTextureForKey.js
Normal file
2
engine/docs/cocos2d/core/textures/removeTextureForKey.js
Normal file
@@ -0,0 +1,2 @@
|
||||
------
|
||||
cc.textureCache.removeTexture("hello.png");
|
2
engine/docs/cocos2d/core/textures/textureForKey.js
Normal file
2
engine/docs/cocos2d/core/textures/textureForKey.js
Normal file
@@ -0,0 +1,2 @@
|
||||
------------------
|
||||
var key = cc.textureCache.textureForKey("hello.png");
|
6
engine/docs/cocos2d/core/utils/CCPath/basename.js
Normal file
6
engine/docs/cocos2d/core/utils/CCPath/basename.js
Normal file
@@ -0,0 +1,6 @@
|
||||
---------------------------------
|
||||
cc.path.basename("a/b.png"); //-->"b.png"
|
||||
cc.path.basename("a/b.png?a=1&b=2"); //-->"b.png"
|
||||
cc.path.basename("a/b.png", ".png"); //-->"b"
|
||||
cc.path.basename("a/b.png?a=1&b=2", ".png"); //-->"b"
|
||||
cc.path.basename("a/b.png", ".txt"); //-->"b.png"
|
6
engine/docs/cocos2d/core/utils/CCPath/changeBasename.js
Normal file
6
engine/docs/cocos2d/core/utils/CCPath/changeBasename.js
Normal file
@@ -0,0 +1,6 @@
|
||||
----------------------------------
|
||||
cc.path.changeBasename("a/b/c.plist", "b.plist"); //-->"a/b/b.plist"
|
||||
cc.path.changeBasename("a/b/c.plist?a=1&b=2", "b.plist"); //-->"a/b/b.plist?a=1&b=2"
|
||||
cc.path.changeBasename("a/b/c.plist", ".png"); //-->"a/b/c.png"
|
||||
cc.path.changeBasename("a/b/c.plist", "b"); //-->"a/b/b"
|
||||
cc.path.changeBasename("a/b/c.plist", "b", true); //-->"a/b/b.plist"
|
3
engine/docs/cocos2d/core/utils/CCPath/changeExtname.js
Normal file
3
engine/docs/cocos2d/core/utils/CCPath/changeExtname.js
Normal file
@@ -0,0 +1,3 @@
|
||||
---------------------------------
|
||||
cc.path.changeExtname("a/b.png", ".plist"); //-->"a/b.plist"
|
||||
cc.path.changeExtname("a/b.png?a=1&b=2", ".plist"); //-->"a/b.plist?a=1&b=2"
|
9
engine/docs/cocos2d/core/utils/CCPath/dirname.js
Normal file
9
engine/docs/cocos2d/core/utils/CCPath/dirname.js
Normal file
@@ -0,0 +1,9 @@
|
||||
---------------------------------
|
||||
* unix
|
||||
cc.path.driname("a/b/c.png"); //-->"a/b"
|
||||
cc.path.driname("a/b/c.png?a=1&b=2"); //-->"a/b"
|
||||
cc.path.dirname("a/b/"); //-->"a/b"
|
||||
cc.path.dirname("c.png"); //-->""
|
||||
* windows
|
||||
cc.path.driname("a\\b\\c.png"); //-->"a\b"
|
||||
cc.path.driname("a\\b\\c.png?a=1&b=2"); //-->"a\b"
|
5
engine/docs/cocos2d/core/utils/CCPath/extname.js
Normal file
5
engine/docs/cocos2d/core/utils/CCPath/extname.js
Normal file
@@ -0,0 +1,5 @@
|
||||
---------------------------
|
||||
cc.path.extname("a/b.png"); //-->".png"
|
||||
cc.path.extname("a/b.png?a=1&b=2"); //-->".png"
|
||||
cc.path.extname("a/b"); //-->null
|
||||
cc.path.extname("a/b?a=1&b=2"); //-->null
|
6
engine/docs/cocos2d/core/utils/CCPath/join.js
Normal file
6
engine/docs/cocos2d/core/utils/CCPath/join.js
Normal file
@@ -0,0 +1,6 @@
|
||||
------------------------------
|
||||
cc.path.join("a", "b.png"); //-->"a/b.png"
|
||||
cc.path.join("a", "b", "c.png"); //-->"a/b/c.png"
|
||||
cc.path.join("a", "b"); //-->"a/b"
|
||||
cc.path.join("a", "b", "/"); //-->"a/b/"
|
||||
cc.path.join("a", "b/", "/"); //-->"a/b/"
|
2
engine/docs/cocos2d/core/utils/base-node/setPosition.js
Normal file
2
engine/docs/cocos2d/core/utils/base-node/setPosition.js
Normal file
@@ -0,0 +1,2 @@
|
||||
node.setPosition(cc.v2(0, 0));
|
||||
node.setPosition(0, 0);
|
@@ -0,0 +1,3 @@
|
||||
---------------------------------
|
||||
var size = cc.winSize;
|
||||
node.setPosition(size.width/2, size.height/2);
|
7
engine/docs/cocos2d/core/value-types/CCColor/color.js
Normal file
7
engine/docs/cocos2d/core/value-types/CCColor/color.js
Normal file
@@ -0,0 +1,7 @@
|
||||
-----------------------
|
||||
// 1. All channels seperately as parameters
|
||||
var color1 = new cc.Color(255, 255, 255, 255);
|
||||
// 2. Convert a hex string to a color
|
||||
var color2 = new cc.Color("#000000");
|
||||
// 3. An color object as parameter
|
||||
var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
|
9
engine/docs/cocos2d/core/value-types/CCColor/lerp.js
Normal file
9
engine/docs/cocos2d/core/value-types/CCColor/lerp.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// Converts a white color to a black one trough time.
|
||||
update: function (dt) {
|
||||
var color = this.node.color;
|
||||
if (color.equals(cc.Color.BLACK)) {
|
||||
return;
|
||||
}
|
||||
this.ratio += dt * 0.1;
|
||||
this.node.color = cc.Color.WHITE.lerp(cc.Color.BLACK, ratio);
|
||||
}
|
4
engine/docs/cocos2d/core/value-types/CCSize/size.js
Normal file
4
engine/docs/cocos2d/core/value-types/CCSize/size.js
Normal file
@@ -0,0 +1,4 @@
|
||||
var size1 = cc.size();
|
||||
var size2 = cc.size(100,100);
|
||||
var size3 = cc.size(size2);
|
||||
var size4 = cc.size({width: 100, height: 100});
|
Reference in New Issue
Block a user