mirror of https://github.com/axmolengine/axmol.git
commit
3187e7647a
1
AUTHORS
1
AUTHORS
|
@ -828,6 +828,7 @@ Developers:
|
|||
Added missing Text Font and Placeholder feature of EditBox for Mac platform
|
||||
HttpRequest uses std::function as callback
|
||||
EditBox: mac secure input
|
||||
Fix a bug that can not get/set text in password mode on Mac OS X
|
||||
|
||||
iSevenDays
|
||||
Fixed a bug that the result of 'malloc' is incompatible with type 'unsigned char *' in Image::saveImageToPNG
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
cocos2d-x-3.2 ??
|
||||
[FIX] Animation3D: getOrCreate is deprecated and replaced with Animation3D::create
|
||||
[FIX] Animate3D: setSpeed() accept negtive value, which means play reverse, getPlayback and setPlayBack are deprecated
|
||||
[FIX] EditBox: can not set/get text in password mode on Mac OS X
|
||||
[FIX] GLView: cursor position is not correct if design resolution is different from device resolution
|
||||
[FIX] Label: color can not be set correctly if using system font
|
||||
[FIX] Lua-binding: support UIVideoPlayer
|
||||
|
@ -10,6 +11,7 @@ cocos2d-x-3.2 ??
|
|||
[FIX] SpriteBatchNode: opacity can not work
|
||||
[FIX] Sprite3D: may crash on Android if playing animation and replace Scene after come from background
|
||||
[FIX] UIdget: opacity is wrong when replace texture
|
||||
[FIX] UIText: can not wrap words automatically
|
||||
[FIX] UITextField: keyboard can not hide if touching space outside of keyboard
|
||||
|
||||
[FIX] Others: don't release singleton objects correctly that are needed in the whole game, which will be treated
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
1503FAC418DA8B6C00F6518C /* tp.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB118DA8B6C00F6518C /* tp.lua */; };
|
||||
1503FAC518DA8B6C00F6518C /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; };
|
||||
1503FAC618DA8B6C00F6518C /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; };
|
||||
156229331973D400009C9067 /* bitExtend.lua in Resources */ = {isa = PBXBuildFile; fileRef = 156229321973D400009C9067 /* bitExtend.lua */; };
|
||||
156229341973D400009C9067 /* bitExtend.lua in Resources */ = {isa = PBXBuildFile; fileRef = 156229321973D400009C9067 /* bitExtend.lua */; };
|
||||
15AECE0B195C0F8A00907DB0 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA0FB65191B933000B170C8 /* MediaPlayer.framework */; };
|
||||
15AECE0F195C1FDD00907DB0 /* cocosvideo.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 3EA0FB5D191B92F100B170C8 /* cocosvideo.mp4 */; };
|
||||
15AECE1F195D0EC500907DB0 /* experimentalConstants.lua in Resources */ = {isa = PBXBuildFile; fileRef = 15AECE1E195D0EC500907DB0 /* experimentalConstants.lua */; };
|
||||
|
@ -1393,6 +1395,7 @@
|
|||
1503FAB018DA8B6C00F6518C /* socket.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = socket.lua; path = ../external/lua/luasocket/socket.lua; sourceTree = "<group>"; };
|
||||
1503FAB118DA8B6C00F6518C /* tp.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = tp.lua; path = ../external/lua/luasocket/tp.lua; sourceTree = "<group>"; };
|
||||
1503FAB218DA8B6C00F6518C /* url.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = url.lua; path = ../external/lua/luasocket/url.lua; sourceTree = "<group>"; };
|
||||
156229321973D400009C9067 /* bitExtend.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = bitExtend.lua; path = "../cocos/scripting/lua-bindings/script/bitExtend.lua"; sourceTree = "<group>"; };
|
||||
15AECE1E195D0EC500907DB0 /* experimentalConstants.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = experimentalConstants.lua; path = "../cocos/scripting/lua-bindings/script/experimentalConstants.lua"; sourceTree = "<group>"; };
|
||||
15C64822165F391E007D4F18 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; };
|
||||
15C64824165F3934007D4F18 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework; sourceTree = DEVELOPER_DIR; };
|
||||
|
@ -5531,6 +5534,7 @@
|
|||
1ABCA36418CD9E060087CE3A /* Lua Common */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
156229321973D400009C9067 /* bitExtend.lua */,
|
||||
15AECE1E195D0EC500907DB0 /* experimentalConstants.lua */,
|
||||
1503FAA918DA8B6C00F6518C /* ftp.lua */,
|
||||
1503FAAA18DA8B6C00F6518C /* headers.lua */,
|
||||
|
@ -7897,6 +7901,7 @@
|
|||
15C90B4918E66C2A00D69802 /* tp.lua in Resources */,
|
||||
1AC35DE918CEE65900F37B72 /* effect1.wav in Resources */,
|
||||
1ABCA38E18CD9E180087CE3A /* GuiConstants.lua in Resources */,
|
||||
156229331973D400009C9067 /* bitExtend.lua in Resources */,
|
||||
15C90B3F18E66C0C00D69802 /* ltn12.lua in Resources */,
|
||||
15C90B4718E66C2400D69802 /* socket.lua in Resources */,
|
||||
15C90B3A18E66BE200D69802 /* ftp.lua in Resources */,
|
||||
|
@ -7939,6 +7944,7 @@
|
|||
15B0870D195AD52000D6F62B /* ActionTimeline in Resources */,
|
||||
15E66FC8192D957100C20A52 /* Sprite3DTest in Resources */,
|
||||
15C90B4418E66C1800D69802 /* mime.lua in Resources */,
|
||||
156229341973D400009C9067 /* bitExtend.lua in Resources */,
|
||||
15C90B4C18E66C3100D69802 /* url.lua in Resources */,
|
||||
1AC35DD618CEE65200F37B72 /* Misc in Resources */,
|
||||
1ABCA37B18CD9E180087CE3A /* CCBReaderLoad.lua in Resources */,
|
||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
|||
|
||||
const char* cocos2dVersion()
|
||||
{
|
||||
return "cocos2d-x 3.2beta0";
|
||||
return "cocos2d-x 3.2";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -160,6 +160,7 @@ void Skin::updateTransform()
|
|||
//
|
||||
// calculate the Quad based on the Affine Matrix
|
||||
//
|
||||
Mat4 transform = getNodeToParentTransform();
|
||||
|
||||
Size &size = _rect.size;
|
||||
|
||||
|
@ -169,13 +170,13 @@ void Skin::updateTransform()
|
|||
float x2 = x1 + size.width;
|
||||
float y2 = y1 + size.height;
|
||||
|
||||
float x = _transform.m[12];
|
||||
float y = _transform.m[13];
|
||||
float x = transform.m[12];
|
||||
float y = transform.m[13];
|
||||
|
||||
float cr = _transform.m[0];
|
||||
float sr = _transform.m[1];
|
||||
float cr2 = _transform.m[5];
|
||||
float sr2 = -_transform.m[4];
|
||||
float cr = transform.m[0];
|
||||
float sr = transform.m[1];
|
||||
float cr2 = transform.m[5];
|
||||
float sr2 = -transform.m[4];
|
||||
float ax = x1 * cr - y1 * sr2 + x;
|
||||
float ay = x1 * sr + y1 * cr2 + y;
|
||||
|
||||
|
|
|
@ -6090,7 +6090,8 @@ int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S)
|
|||
return 0;
|
||||
unsigned int ret = cobj->getTileGIDAt(arg0);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||
return 1;
|
||||
tolua_pushnumber(tolua_S,(lua_Number)0);
|
||||
return 2;
|
||||
}
|
||||
if (argc == 2)
|
||||
{
|
||||
|
@ -6105,7 +6106,8 @@ int lua_cocos2dx_TMXLayer_getTileGIDAt(lua_State* tolua_S)
|
|||
|
||||
unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||
return 1;
|
||||
tolua_pushnumber(tolua_S,(lua_Number)arg1);
|
||||
return 2;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileGIDAt",argc, 1);
|
||||
return 0;
|
||||
|
@ -6471,7 +6473,8 @@ static int lua_cocos2dx_FastTMXLayer_getTileGIDAt(lua_State* tolua_S)
|
|||
return 0;
|
||||
int ret = cobj->getTileGIDAt(arg0);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||
return 1;
|
||||
tolua_pushnumber(tolua_S,(lua_Number)0);
|
||||
return 2;
|
||||
}
|
||||
if (argc == 2)
|
||||
{
|
||||
|
@ -6486,7 +6489,8 @@ static int lua_cocos2dx_FastTMXLayer_getTileGIDAt(lua_State* tolua_S)
|
|||
|
||||
unsigned int ret = cobj->getTileGIDAt(arg0, (cocos2d::TMXTileFlags*)&arg1);
|
||||
tolua_pushnumber(tolua_S,(lua_Number)ret);
|
||||
return 1;
|
||||
tolua_pushnumber(tolua_S,(lua_Number)arg1);
|
||||
return 2;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getTileGIDAt",argc, 1);
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
-- bit operation
|
||||
|
||||
bit = bit or {}
|
||||
bit.data32 = {}
|
||||
for i=1,32 do
|
||||
bit.data32[i]=2^(32-i)
|
||||
end
|
||||
|
||||
function bit._b2d(arg)
|
||||
local nr=0
|
||||
for i=1,32 do
|
||||
if arg[i] ==1 then
|
||||
nr=nr+bit.data32[i]
|
||||
end
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function bit._d2b(arg)
|
||||
arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1)
|
||||
local tr={}
|
||||
for i=1,32 do
|
||||
if arg >= bit.data32[i] then
|
||||
tr[i]=1
|
||||
arg=arg-bit.data32[i]
|
||||
else
|
||||
tr[i]=0
|
||||
end
|
||||
end
|
||||
return tr
|
||||
end
|
||||
|
||||
function bit._and(a,b)
|
||||
local op1=bit._d2b(a)
|
||||
local op2=bit._d2b(b)
|
||||
local r={}
|
||||
|
||||
for i=1,32 do
|
||||
if op1[i]==1 and op2[i]==1 then
|
||||
r[i]=1
|
||||
else
|
||||
r[i]=0
|
||||
end
|
||||
end
|
||||
return bit._b2d(r)
|
||||
|
||||
end
|
||||
|
||||
function bit._rshift(a,n)
|
||||
local op1=bit._d2b(a)
|
||||
n = n <= 32 and n or 32
|
||||
n = n >= 0 and n or 0
|
||||
|
||||
for i=32, n+1, -1 do
|
||||
op1[i] = op1[i-n]
|
||||
end
|
||||
for i=1, n do
|
||||
op1[i] = 0
|
||||
end
|
||||
|
||||
return bit._b2d(op1)
|
||||
end
|
||||
|
||||
function bit._not(a)
|
||||
local op1=bit._d2b(a)
|
||||
local r={}
|
||||
|
||||
for i=1,32 do
|
||||
if op1[i]==1 then
|
||||
r[i]=0
|
||||
else
|
||||
r[i]=1
|
||||
end
|
||||
end
|
||||
return bit._b2d(r)
|
||||
end
|
||||
|
||||
function bit._or(a,b)
|
||||
local op1=bit._d2b(a)
|
||||
local op2=bit._d2b(b)
|
||||
local r={}
|
||||
|
||||
for i=1,32 do
|
||||
if op1[i]==1 or op2[i]==1 then
|
||||
r[i]=1
|
||||
else
|
||||
r[i]=0
|
||||
end
|
||||
end
|
||||
return bit._b2d(r)
|
||||
end
|
||||
|
||||
bit.band = bit.band or bit._and
|
||||
bit.rshift = bit.rshift or bit._rshift
|
||||
bit.bnot = bit.bnot or bit._not
|
|
@ -1137,7 +1137,7 @@ float Layout::calculateNearestDistance(Widget* baseWidget)
|
|||
return distance;
|
||||
}
|
||||
|
||||
float Layout::calculateFarestDistance(cocos2d::ui::Widget *baseWidget)
|
||||
float Layout::calculateFarthestDistance(cocos2d::ui::Widget *baseWidget)
|
||||
{
|
||||
float distance = -FLT_MAX;
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ float Layout::calculateFarestDistance(cocos2d::ui::Widget *baseWidget)
|
|||
Layout *layout = dynamic_cast<Layout*>(node);
|
||||
int length;
|
||||
if (layout) {
|
||||
length = layout->calculateFarestDistance(baseWidget);
|
||||
length = layout->calculateFarthestDistance(baseWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1231,7 +1231,7 @@ int Layout::findNearestChildWidgetIndex(FocusDirection direction, Widget* baseWi
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget)
|
||||
int Layout::findFarthestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Widget *baseWidget)
|
||||
{
|
||||
if (baseWidget == nullptr || baseWidget == this)
|
||||
{
|
||||
|
@ -1256,7 +1256,7 @@ int Layout::findFarestChildWidgetIndex(FocusDirection direction, cocos2d::ui::Wi
|
|||
Layout *layout = dynamic_cast<Layout*>(w);
|
||||
if (layout)
|
||||
{
|
||||
length = layout->calculateFarestDistance(baseWidget);
|
||||
length = layout->calculateFarthestDistance(baseWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1337,11 +1337,11 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget)
|
|||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
}
|
||||
else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
}else if(dir == FocusDirection::RIGHT){
|
||||
if (previousWidgetPosition.x > widgetPosition.x) {
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
|
@ -1350,13 +1350,13 @@ void Layout::findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget)
|
|||
if (previousWidgetPosition.y > widgetPosition.y) {
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
}else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
}else if(dir == FocusDirection::UP){
|
||||
if (previousWidgetPosition.y < widgetPosition.y) {
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findNearestChildWidgetIndex, this);
|
||||
}else{
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarestChildWidgetIndex, this);
|
||||
onPassFocusToChild = CC_CALLBACK_2(Layout::findFarthestChildWidgetIndex, this);
|
||||
}
|
||||
}else{
|
||||
CCASSERT(0, "invalid direction!");
|
||||
|
|
|
@ -365,11 +365,11 @@ protected:
|
|||
|
||||
/**
|
||||
* When the layout get focused, it the layout pass the focus to its child, it will use this method to determine which child
|
||||
* will get the focus. The current algorithm to determine which child will get focus is farest-distance-priority algorithm
|
||||
* will get the focus. The current algorithm to determine which child will get focus is farthest-distance-priority algorithm
|
||||
*@param dir next focused widget direction
|
||||
*@return The index of child widget in the container
|
||||
*/
|
||||
int findFarestChildWidgetIndex(FocusDirection direction, Widget* baseWidget);
|
||||
int findFarthestChildWidgetIndex(FocusDirection direction, Widget* baseWidget);
|
||||
|
||||
/**
|
||||
* caculate the nearest distance between the baseWidget and the children of the layout
|
||||
|
@ -379,15 +379,15 @@ protected:
|
|||
float calculateNearestDistance(Widget* baseWidget);
|
||||
|
||||
/**
|
||||
* caculate the farest distance between the baseWidget and the children of the layout
|
||||
* caculate the farthest distance between the baseWidget and the children of the layout
|
||||
*@param the base widget which will be used to caculate the distance between the layout's children and itself
|
||||
*@return return the farest distance between the baseWidget and the layout's children
|
||||
*@return return the farthest distance between the baseWidget and the layout's children
|
||||
*/
|
||||
|
||||
float calculateFarestDistance(Widget* baseWidget);
|
||||
float calculateFarthestDistance(Widget* baseWidget);
|
||||
|
||||
/**
|
||||
* when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farest distance algorithm or not
|
||||
* when a layout pass the focus to it's child, use this method to determine which algorithm to use, nearest or farthest distance algorithm or not
|
||||
*/
|
||||
void findProperSearchingFunctor(FocusDirection dir, Widget* baseWidget);
|
||||
|
||||
|
|
|
@ -296,7 +296,6 @@ void Text::labelScaleChangedWithSize()
|
|||
{
|
||||
if (_ignoreSize)
|
||||
{
|
||||
_labelRenderer->setDimensions(0,0);
|
||||
_labelRenderer->setScale(1.0f);
|
||||
_normalScaleValueX = _normalScaleValueY = 1.0f;
|
||||
}
|
||||
|
|
|
@ -456,16 +456,18 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* Ignore the widget size
|
||||
*
|
||||
* @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
|
||||
* Note: when you set _ignoreSize to true, no matther you call setContentSize or not,
|
||||
* the widget size is always equal to the return value of the member function getVirtualRendererSize.
|
||||
*
|
||||
* @param ignore, set member variabl _ignoreSize to ignore
|
||||
*/
|
||||
virtual void ignoreContentAdaptWithSize(bool ignore);
|
||||
|
||||
/**
|
||||
* Gets the widget if is ignore it's size.
|
||||
* Query whether the widget ignores user deinfed content size or not
|
||||
*
|
||||
* @param ignore, true that widget will ignore it's size, use texture size, false otherwise. Default value is true.
|
||||
* @return bool
|
||||
*/
|
||||
bool isIgnoreContentAdaptWithSize() const;
|
||||
|
||||
|
@ -485,15 +487,9 @@ public:
|
|||
*/
|
||||
virtual Node* getVirtualRenderer();
|
||||
|
||||
// /**
|
||||
// * Gets the content size of widget.
|
||||
// *
|
||||
// * Content size is widget's texture size.
|
||||
// */
|
||||
// virtual const Size& getContentSize() const;
|
||||
|
||||
virtual const Size& getVirtualRendererSize() const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the "class name" of widget.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# cocos2d-x v3.2rc0 Release Notes #
|
||||
# cocos2d-x v3.2 Release Notes #
|
||||
|
||||
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
|
||||
|
||||
- [cocos2d-x v3.2rc0 Release Notes](#user-content-cocos2d-x-v32rc0-release-notes)
|
||||
- [cocos2d-x v3.2 Release Notes](#user-content-cocos2d-x-v32-release-notes)
|
||||
- [Misc Information](#user-content-misc-information)
|
||||
- [Requirements](#user-content-requirements)
|
||||
- [Runtime Requirements](#user-content-runtime-requirements)
|
||||
|
@ -13,21 +13,23 @@
|
|||
- [Windows](#user-content-windows)
|
||||
- [Linux](#user-content-linux)
|
||||
- [How to start a new game](#user-content-how-to-start-a-new-game)
|
||||
- [Highlights of v3.2rc0](#user-content-highlights-of-v32rc0)
|
||||
- [Highlights of v3.2](#user-content-highlights-of-v32)
|
||||
- [Documents](#user-content-documents)
|
||||
- [Toolchain requirement changed](#user-content-toolchain-requirement-changed)
|
||||
- [Features in detail](#user-content-features-in-detail)
|
||||
- [Sprite3d](#user-content-sprite3d)
|
||||
- [Sprite3D & Animation3D](#user-content-sprite3d--animation3d)
|
||||
- [fbx-conv usage](#user-content-fbx-conv-usage)
|
||||
- [Controller support](#user-content-controller-support)
|
||||
- [Game controller](#user-content-game-controller)
|
||||
- [Fast tilemap](#user-content-fast-tilemap)
|
||||
- [Node::enumerateChildren](#user-content-nodeenumeratechildren)
|
||||
- [utils::findChildren](#user-content-utilsfindchildren)
|
||||
- [Node::setNormalizedPosition](#user-content-nodesetnormalizedposition)
|
||||
|
||||
# Misc Information
|
||||
|
||||
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2rc0.zip
|
||||
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2rc0/CHANGELOG
|
||||
* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2rc0/index.html
|
||||
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2.zip
|
||||
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2/CHANGELOG
|
||||
* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2/index.html
|
||||
* v3.0 Release Notes can be found here: [v3.0 Release Notes](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0/docs/RELEASE_NOTES.md)
|
||||
|
||||
# Requirements
|
||||
|
@ -114,14 +116,22 @@ Run
|
|||
|
||||
Please refer to this document: [ReadMe](../README.md)
|
||||
|
||||
# Highlights of v3.2rc0
|
||||
# Highlights of v3.2
|
||||
|
||||
* `fbx-conv` support generating binary format, and `Sprite3D` support it
|
||||
* about 20% performance improved in `Sprite3D`
|
||||
* game controller support
|
||||
* fast tilemap support, it is faster for static tilemap
|
||||
* physics body supports scale and rotation
|
||||
* added Node::enumearteChildren(), and support c++ 11 regular expression
|
||||
* `Animation3D`/`Animate3D`, new nodes for 3d animation
|
||||
* `fbx-conv` supports generating binary format which is supported by `Sprite3D`
|
||||
* Game controller support
|
||||
* Fast tilemap support
|
||||
* Added `utils::cpatureScreen` to take screenshot
|
||||
* Physics body supports scale and rotation
|
||||
* Added `Node::enumerateChildren` and `utils::findChildren`, and support c++ 11 regular expression
|
||||
* Added `Node::setNormalizedPosition`, `Node`'s position in pixel will be calculated according its parent's content size
|
||||
|
||||
# Documents
|
||||
|
||||
* [Sprite3D & Animation3D](http://cocos2d-x.org/wiki/Sprite3D)
|
||||
* [Game controller](http://www.cocos2d-x.org/wiki/Game_Controller)
|
||||
* [How to compile shader on WP8](http://cocos2d-x.org/wiki/How_to_update_wp8_shader)
|
||||
|
||||
# Toolchain requirement changed
|
||||
|
||||
|
@ -133,14 +143,19 @@ Please refer to this document: [ReadMe](../README.md)
|
|||
|
||||
# Features in detail
|
||||
|
||||
## Sprite3d
|
||||
## Sprite3D & Animation3D
|
||||
|
||||
Sample code to use binary version
|
||||
```c++
|
||||
auto sprite3d = Sprite3D::create("filename.c3b");
|
||||
addChild(sprite3d);
|
||||
|
||||
auto animation3d = Animation3D("filename.c3b");
|
||||
auto animate3d = Animate3D::create(animation3d);
|
||||
sprite3d->runAction(RepeatForEver::create(animate));
|
||||
```
|
||||
|
||||
Detail information please refer to [Sprite3D & Animation3D](http://cocos2d-x.org/wiki/Sprite3D).
|
||||
|
||||
### `fbx-conv` usage
|
||||
|
||||
|
@ -164,19 +179,43 @@ Options:
|
|||
* -b: export binary format
|
||||
* -t: export text format
|
||||
|
||||
## Controller support
|
||||
## Game controller
|
||||
|
||||
Supported controller type:
|
||||
|
||||
* amazon tv
|
||||
* Android standard controllers
|
||||
* Amazon tv
|
||||
* OUYA
|
||||
* Moga
|
||||
* Nibiru
|
||||
* iOS standard controllers
|
||||
|
||||
In order to use controller on Android, you should refer to this Android project(`COCOS2DX_ROOT/cocos/platform/android/ControllerManualAdapter`).
|
||||
Sample codes
|
||||
```c++
|
||||
// register event listener
|
||||
auto listener = EventListenerController::create();
|
||||
listner->onKeyDown = ...
|
||||
...
|
||||
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
|
||||
|
||||
Full demo please refer to `COCOS2DX_ROOT/tests/game-controler-test`.
|
||||
// start connecting controller
|
||||
Controller::startDiscoveryController();
|
||||
|
||||
// handler key down/ key up event
|
||||
void GameControllerTest::onKeyDown(Controller *controller, int keyCode, Event *event)
|
||||
{
|
||||
switch (keyCode)
|
||||
{
|
||||
case Controller::Key::BUTTON_A:
|
||||
...
|
||||
break;
|
||||
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Detail information please refer to [Game controller](http://www.cocos2d-x.org/wiki/Game_Controller).
|
||||
|
||||
## Fast tilemap
|
||||
|
||||
|
@ -192,7 +231,7 @@ Full demo please refer to `COCOS2DX_ROOT/tests/cpp-tests/Classes/TileMapTest/Til
|
|||
|
||||
## Node::enumerateChildren
|
||||
|
||||
This functions is used to enumerate children of a `Node` recursively. It supports c++ 11 regular expression.
|
||||
This functions is used to enumerate children of a `Node`. It supports c++ 11 regular expression.
|
||||
|
||||
```c++
|
||||
// Find nodes whose name is 'nameToFind' and end with digits.
|
||||
|
@ -200,6 +239,12 @@ node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool {
|
|||
...
|
||||
return false; // return true to stop at first match
|
||||
});
|
||||
|
||||
// Find nodes whose name is 'nameToFind' and end with digits recursively.
|
||||
node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool {
|
||||
...
|
||||
return false; // return true to stop at first match
|
||||
});
|
||||
```
|
||||
|
||||
Full test please refer to `NodeNameTest` in `COCOS2DX_ROOT/tests/cpp-tests/NodeTest/NodeTest.cpp`.
|
||||
|
@ -215,3 +260,18 @@ auto children = utils::findChildren(node, "nameToFind");
|
|||
|
||||
...
|
||||
```
|
||||
|
||||
## Node::setNormalizedPosition
|
||||
|
||||
Can use this function to set Node's position(x,y) using value between 0 and 1. `Can use this function when it has a parent node.` The positions in pixels is calculated like the following:
|
||||
|
||||
```c++
|
||||
// pseudo code
|
||||
void setNormalizedPosition(Vec2 pos)
|
||||
{
|
||||
Size s = getParent()->getContentSize();
|
||||
_position = pos * s;
|
||||
}
|
||||
```
|
||||
|
||||
Full test please refer to `NodeNormalizedPositionTest1/2` in `tests/cpp-tests/Classes/NodeTest/NodeTest.cpp`.
|
||||
|
|
|
@ -404,11 +404,15 @@ void EditBoxImplMac::setText(const char* pText)
|
|||
{
|
||||
NSString *string = [NSString stringWithUTF8String:pText];
|
||||
_sysEdit.textField.stringValue = string;
|
||||
_sysEdit.textField.stringValue = string;
|
||||
_sysEdit.secureTextField.stringValue = string;
|
||||
}
|
||||
|
||||
const char* EditBoxImplMac::getText(void)
|
||||
{
|
||||
if (_sysEdit.secureTextField.superview) {
|
||||
return [_sysEdit.secureTextField.stringValue UTF8String];
|
||||
}
|
||||
|
||||
return [_sysEdit.textField.stringValue UTF8String];
|
||||
}
|
||||
|
||||
|
|
|
@ -4038,6 +4038,7 @@
|
|||
"cocos/scripting/lua-bindings/script/Opengl.lua",
|
||||
"cocos/scripting/lua-bindings/script/OpenglConstants.lua",
|
||||
"cocos/scripting/lua-bindings/script/StudioConstants.lua",
|
||||
"cocos/scripting/lua-bindings/script/bitExtend.lua",
|
||||
"cocos/scripting/lua-bindings/script/experimentalConstants.lua",
|
||||
"cocos/scripting/lua-bindings/script/extern.lua",
|
||||
"cocos/scripting/lua-bindings/script/json.lua",
|
||||
|
|
|
@ -40,10 +40,25 @@ bool UITextTest_LineWrap::init()
|
|||
_uiLayer->addChild(alert);
|
||||
|
||||
// Create the line wrap
|
||||
Text* text = Text::create("Text can line wrap","AmericanTypewriter",32);
|
||||
Text* text = Text::create("TextArea Widget can line wrap","AmericanTypewriter",32);
|
||||
text->ignoreContentAdaptWithSize(false);
|
||||
text->setContentSize(Size(280, 150));
|
||||
text->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
text->setTouchScaleChangeEnabled(true);
|
||||
text->setTouchEnabled(true);
|
||||
text->addTouchEventListener([=](Ref* sender, Widget::TouchEventType type)
|
||||
{
|
||||
if (type == Widget::TouchEventType::ENDED)
|
||||
{
|
||||
if ((int)text->getContentSize().width == 280)
|
||||
{
|
||||
text->setContentSize(Size(380,100));
|
||||
}else
|
||||
{
|
||||
text->setContentSize(Size(280, 150));
|
||||
}
|
||||
}
|
||||
});
|
||||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getContentSize().height / 8.0f));
|
||||
_uiLayer->addChild(text);
|
||||
|
||||
|
|
|
@ -25,6 +25,15 @@ SceneEditorTestLayer.title =
|
|||
"Trigger Test",
|
||||
}
|
||||
|
||||
SceneEditorTestLayer.loadtypeStr=
|
||||
{
|
||||
"change to load \nwith binary file",
|
||||
"change to load \nwith json file"
|
||||
}
|
||||
|
||||
SceneEditorTestLayer.fileName = ""
|
||||
SceneEditorTestLayer.rootNode = nil
|
||||
|
||||
function SceneEditorTestLayer.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
|
@ -70,9 +79,44 @@ function SceneEditorTestLayer:createTitle()
|
|||
title:setPosition( cc.p(VisibleRect:center().x, VisibleRect:top().y - 30))
|
||||
end
|
||||
|
||||
function SceneEditorTestLayer:loadFileChangeHelper(filePathName)
|
||||
local indexTable = {}
|
||||
local index = 0
|
||||
|
||||
while true do
|
||||
index = string.find(filePathName, "%.", index + 1)
|
||||
if nil == index then
|
||||
break
|
||||
end
|
||||
|
||||
indexTable[#indexTable + 1] = index
|
||||
end
|
||||
|
||||
if #indexTable == 0 then
|
||||
return filePathName
|
||||
end
|
||||
|
||||
local lastIndex = indexTable[#indexTable]
|
||||
if lastIndex == 1 then
|
||||
return filePathName
|
||||
end
|
||||
local renamePathName= string.sub(filePathName, 1, lastIndex - 1)
|
||||
|
||||
if self.isCsbLoad then
|
||||
renamePathName = renamePathName .. ".csb"
|
||||
else
|
||||
renamePathName = renamePathName .. ".json"
|
||||
end
|
||||
print("renamePath is", renamePathName)
|
||||
return renamePathName
|
||||
end
|
||||
|
||||
function SceneEditorTestLayer:defaultPlay()
|
||||
|
||||
end
|
||||
|
||||
function SceneEditorTestLayer:createMenu()
|
||||
local menu = cc.Menu:create()
|
||||
|
||||
local function pre()
|
||||
local scene = cc.Scene:create()
|
||||
scene:addChild(backSceneEditorTest())
|
||||
|
@ -118,6 +162,41 @@ function SceneEditorTestLayer:createMenu()
|
|||
end
|
||||
end
|
||||
|
||||
self.isCsbLoad = false
|
||||
self.loadtypeLabel = cc.Label:createWithSystemFont(self.loadtypeStr[1], "Arial", 12)
|
||||
local function changeLoadTypeCallback(tag,sender)
|
||||
self.isCsbLoad = not self.isCsbLoad
|
||||
if self.isCsbLoad then
|
||||
self.loadtypeLabel:setString(self.loadtypeStr[2])
|
||||
else
|
||||
self.loadtypeLabel:setString(self.loadtypeStr[1])
|
||||
end
|
||||
|
||||
if sceneEditorTestIdx == #SceneEditorTestLayer.title then
|
||||
self:unscheduleUpdate()
|
||||
end
|
||||
|
||||
SceneEditorTestLayer.fileName = self:loadFileChangeHelper(SceneEditorTestLayer.fileName)
|
||||
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
self:removeChild(SceneEditorTestLayer.rootNode, true)
|
||||
SceneEditorTestLayer.rootNode = ccs.SceneReader:getInstance():createNodeWithSceneFile(SceneEditorTestLayer.fileName)
|
||||
if SceneEditorTestLayer.rootNode == nil then
|
||||
return
|
||||
end
|
||||
self:defaultPlay()
|
||||
self:addChild(SceneEditorTestLayer.rootNode, 0, 1)
|
||||
end
|
||||
end
|
||||
|
||||
local loadTypeItem = cc.MenuItemLabel:create(self.loadtypeLabel)
|
||||
loadTypeItem:registerScriptTapHandler(changeLoadTypeCallback)
|
||||
local loadtypeMenu = cc.Menu:create()
|
||||
loadtypeMenu:addChild(loadTypeItem)
|
||||
loadtypeMenu:setPosition(cc.p(0,0))
|
||||
loadTypeItem:setPosition(cc.p(VisibleRect:rightTop().x -80,VisibleRect:rightTop().y -30))
|
||||
self:addChild(loadtypeMenu, 100)
|
||||
|
||||
local backMenu = cc.Menu:create()
|
||||
cc.MenuItemFont:setFontName("Arial")
|
||||
cc.MenuItemFont:setFontSize(24)
|
||||
|
@ -145,9 +224,16 @@ end
|
|||
|
||||
function LoadSceneEdtiorFileTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.json")
|
||||
SceneEditorTestLayer.fileName = "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
self:defaultPlay()
|
||||
return node
|
||||
end
|
||||
|
||||
function LoadSceneEdtiorFileTest:defaultPlay()
|
||||
|
||||
end
|
||||
|
||||
function LoadSceneEdtiorFileTest:onEnter()
|
||||
self:createMenu()
|
||||
self:createTitle()
|
||||
|
@ -191,13 +277,9 @@ end
|
|||
function SpriteComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/SpriteComponentTest/SpriteComponentTest.json")
|
||||
if nil ~= node then
|
||||
local action1 = cc.Blink:create(2, 10)
|
||||
local action2 = cc.Blink:create(2, 5)
|
||||
|
||||
local sister1 = node:getChildByTag(10003):getComponent("CCSprite")
|
||||
sister1:getNode():runAction(action1)
|
||||
local sister2 = node:getChildByTag(10004):getComponent("CCSprite")
|
||||
sister2:getNode():runAction(action2)
|
||||
SceneEditorTestLayer.fileName = "scenetest/SpriteComponentTest/SpriteComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
|
@ -209,8 +291,19 @@ function SpriteComponentTest:onEnter()
|
|||
local root = self:createGameScene()
|
||||
if nil ~= root then
|
||||
self:addChild(root, 0, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function SpriteComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local action1 = cc.Blink:create(2, 10)
|
||||
local action2 = cc.Blink:create(2, 5)
|
||||
|
||||
local sister1 = SceneEditorTestLayer.rootNode:getChildByTag(10003):getComponent("CCSprite")
|
||||
sister1:getNode():runAction(action1)
|
||||
local sister2 = SceneEditorTestLayer.rootNode:getChildByTag(10004):getComponent("CCSprite")
|
||||
sister2:getNode():runAction(action2)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function SpriteComponentTest.create()
|
||||
|
@ -246,14 +339,23 @@ end
|
|||
function ArmatureComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ArmatureComponentTest/ArmatureComponentTest.json")
|
||||
if nil ~= node then
|
||||
SceneEditorTestLayer.fileName = "scenetest/ArmatureComponentTest/ArmatureComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function ArmatureComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootName ~= nil then
|
||||
local blowFish = node:getChildByTag(10007):getComponent("CCArmature")
|
||||
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
|
||||
local butterflyfish = node:getChildByTag(10008):getComponent("CCArmature")
|
||||
butterflyfish:getNode():runAction(CCMoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function ArmatureComponentTest:onEnter()
|
||||
|
@ -299,23 +401,31 @@ end
|
|||
function UIComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/UIComponentTest/UIComponentTest.json")
|
||||
if nil ~= node then
|
||||
local render = node:getChildByTag(10025):getComponent("GUIComponent")
|
||||
SceneEditorTestLayer.fileName = "scenetest/UIComponentTest/UIComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function UIComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local render = SceneEditorTestLayer.rootNode:getChildByTag(10025):getComponent("GUIComponent")
|
||||
local widget = render:getNode()
|
||||
local button = widget:getChildByName("Button_156")
|
||||
local function onTouch(sender, eventType)
|
||||
if eventType == ccui.TouchEventType.began then
|
||||
local blowFish = node:getChildByTag(10010):getComponent("CCArmature")
|
||||
local blowFish = SceneEditorTestLayer.rootNode:getChildByTag(10010):getComponent("CCArmature")
|
||||
blowFish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
|
||||
local butterflyfish = node:getChildByTag(10011):getComponent("CCArmature")
|
||||
local butterflyfish = SceneEditorTestLayer.rootNode:getChildByTag(10011):getComponent("CCArmature")
|
||||
butterflyfish:getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
end
|
||||
end
|
||||
|
||||
button:addTouchEventListener(onTouch)
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function UIComponentTest:onEnter()
|
||||
|
@ -361,7 +471,18 @@ end
|
|||
function TmxMapComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TmxMapComponentTest/TmxMapComponentTest.json")
|
||||
if nil ~= node then
|
||||
local tmxMap = node:getChildByTag(10015):getComponent("CCTMXTiledMap")
|
||||
SceneEditorTestLayer.fileName = "scenetest/TmxMapComponentTest/TmxMapComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function TmxMapComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local tmxMap = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCTMXTiledMap")
|
||||
local actionTo = cc.SkewTo:create(2, 0.0, 2.0)
|
||||
local rotateTo = cc.RotateTo:create(2, 61.0)
|
||||
local actionScaleTo = cc.ScaleTo:create(2, -0.44, 0.47)
|
||||
|
@ -374,8 +495,6 @@ function TmxMapComponentTest:createGameScene()
|
|||
tmxMap:getNode():runAction(cc.Sequence:create(rotateTo, rotateToBack))
|
||||
tmxMap:getNode():runAction(cc.Sequence:create(actionScaleTo, actionScaleToBack))
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function TmxMapComponentTest:onEnter()
|
||||
|
@ -421,13 +540,22 @@ end
|
|||
function ParticleComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/ParticleComponentTest/ParticleComponentTest.json")
|
||||
if nil ~= node then
|
||||
local particle = node:getChildByTag(10020):getComponent("CCParticleSystemQuad")
|
||||
SceneEditorTestLayer.fileName = "scenetest/ParticleComponentTest/ParticleComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function ParticleComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local particle = SceneEditorTestLayer.rootNode:getChildByTag(10020):getComponent("CCParticleSystemQuad")
|
||||
local jump = cc.JumpBy:create(5, cc.p(-500,0), 50, 4)
|
||||
local action = cc.Sequence:create( jump, jump:reverse())
|
||||
particle:getNode():runAction(action)
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function ParticleComponentTest:onEnter()
|
||||
|
@ -473,13 +601,24 @@ end
|
|||
function EffectComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/EffectComponentTest/EffectComponentTest.json")
|
||||
if nil ~= node then
|
||||
local render = node:getChildByTag(10015):getComponent("CCArmature")
|
||||
SceneEditorTestLayer.fileName = "scenetest/EffectComponentTest/EffectComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function EffectComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local render = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCArmature")
|
||||
local armature = render:getNode()
|
||||
local function animationEvent(armatureBack,movementType,movementID)
|
||||
local id = movementID
|
||||
if movementType == ccs.MovementEventType.loopComplete then
|
||||
if id == "Fire" then
|
||||
local audio = node:getChildByTag(10015):getComponent("CCComAudio")
|
||||
local audio = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCComAudio")
|
||||
audio:playEffect()
|
||||
end
|
||||
end
|
||||
|
@ -487,8 +626,6 @@ function EffectComponentTest:createGameScene()
|
|||
|
||||
armature:getAnimation():setMovementEventCallFunc(animationEvent)
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function EffectComponentTest:onEnter()
|
||||
|
@ -534,13 +671,22 @@ end
|
|||
function BackgroundComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/BackgroundComponentTest/BackgroundComponentTest.json")
|
||||
if nil ~= node then
|
||||
local audio = node:getComponent("CCBackgroundAudio")
|
||||
audio:playBackgroundMusic()
|
||||
SceneEditorTestLayer.fileName = "scenetest/BackgroundComponentTest/BackgroundComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
|
||||
self:defaultPlay()
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function BackgroundComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local audio = SceneEditorTestLayer.rootNode:getComponent("CCBackgroundAudio")
|
||||
audio:playBackgroundMusic()
|
||||
end
|
||||
end
|
||||
|
||||
function BackgroundComponentTest:onEnter()
|
||||
self:createMenu()
|
||||
self:createTitle()
|
||||
|
@ -583,11 +729,21 @@ end
|
|||
|
||||
function AttributeComponentTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/AttributeComponentTest/AttributeComponentTest.json")
|
||||
local attribute = node:getChildByTag(10015):getComponent("CCComAttribute")
|
||||
print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP")))
|
||||
if nil ~= node then
|
||||
SceneEditorTestLayer.fileName = "scenetest/AttributeComponentTest/AttributeComponentTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
self:defaultPlay()
|
||||
end
|
||||
return node
|
||||
end
|
||||
|
||||
function AttributeComponentTest:defaultPlay()
|
||||
if SceneEditorTestLayer.rootNode ~= nil then
|
||||
local attribute = SceneEditorTestLayer.rootNode:getChildByTag(10015):getComponent("CCComAttribute")
|
||||
print(string.format("Name: %s, HP: %f, MP: %f", attribute:getString("name"), attribute:getFloat("maxHP"), attribute:getFloat("maxMP")))
|
||||
end
|
||||
end
|
||||
|
||||
function AttributeComponentTest:onEnter()
|
||||
self:createMenu()
|
||||
self:createTitle()
|
||||
|
@ -631,7 +787,12 @@ end
|
|||
|
||||
function TriggerTest:createGameScene()
|
||||
local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/TriggerTest/TriggerTest.json")
|
||||
if nil ~= node then
|
||||
SceneEditorTestLayer.fileName = "scenetest/TriggerTest/TriggerTest.json"
|
||||
SceneEditorTestLayer.rootNode = node
|
||||
|
||||
self:defaultPlay()
|
||||
end
|
||||
return node
|
||||
end
|
||||
|
||||
|
@ -658,6 +819,17 @@ function TriggerTest:onEnter()
|
|||
local root = self:createGameScene()
|
||||
if nil ~= root then
|
||||
self:addChild(root, 0, 1)
|
||||
local function onTouchEvent(touch, event)
|
||||
if eventType == "began" then
|
||||
return self:onTouchBegan(touch, event)
|
||||
elseif eventType == "moved" then
|
||||
self:onTouchMoved(touch, event)
|
||||
elseif eventType == "ended" then
|
||||
self:onTouchEnded(touch, event)
|
||||
elseif eventType == "cancelled" then
|
||||
self:onTouchCancelled(touch, event)
|
||||
end
|
||||
end
|
||||
self._touchListener = nil
|
||||
local listener = cc.EventListenerTouchOneByOne:create()
|
||||
listener:setSwallowTouches(true)
|
||||
|
@ -668,20 +840,27 @@ function TriggerTest:onEnter()
|
|||
local eventDispatcher = self:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, self)
|
||||
self._touchListener = listener
|
||||
|
||||
self:unscheduleUpdate()
|
||||
local function update(dt)
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_UPDATESCENE)
|
||||
end
|
||||
self:scheduleUpdateWithPriorityLua(update,0)
|
||||
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function TriggerTest:defaultPlay()
|
||||
|
||||
end
|
||||
|
||||
function TriggerTest:onExit()
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
|
||||
self:unscheduleUpdate()
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
|
||||
local dispatcher = self:getEventDispatcher()
|
||||
dispatcher:removeEventListener(self._touchListener)
|
||||
self._touchListener = nil
|
||||
ccs.TriggerMng.destroyInstance()
|
||||
ccs.ArmatureDataManager:destroyInstance()
|
||||
ccs.SceneReader:destroyInstance()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require "src/ExtensionTest/CocosBuilderTest"
|
||||
require "src/ExtensionTest/WebProxyTest"
|
||||
require "src/ExtensionTest/SceneEditorTest"
|
||||
|
||||
local LINE_SPACE = 40
|
||||
local kItemTagBasic = 1000
|
||||
|
@ -14,8 +13,7 @@ local ExtensionTestEnum =
|
|||
TEST_EDITBOX = 4,
|
||||
TEST_TABLEVIEW = 5,
|
||||
TEST_SCROLLVIEW = 6,
|
||||
TEST_STUDIOSCENE = 7,
|
||||
TEST_MAX_COUNT = 8,
|
||||
TEST_MAX_COUNT = 7,
|
||||
}
|
||||
|
||||
local testsName =
|
||||
|
@ -27,7 +25,6 @@ local testsName =
|
|||
"EditBoxTest",
|
||||
"TableViewTest",
|
||||
"ScrollViewTest",
|
||||
"CocoStudioSceneTest",
|
||||
}
|
||||
|
||||
|
||||
|
@ -1190,7 +1187,6 @@ local CreateExtensionsTestTable =
|
|||
runEditBoxTest,
|
||||
runTableViewTest,
|
||||
runScrollViewTest,
|
||||
runStudioSceneTest,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,270 +0,0 @@
|
|||
require "CCBReaderLoad"
|
||||
|
||||
function SceneEditorTestLayer(filename)
|
||||
|
||||
local layer = cc.Layer:create()
|
||||
local isCsbLoad = false;
|
||||
local loadtypeStr = {"change to load \nwith binary file","change to load \nwith json file"}
|
||||
local loadtypelb = cc.Label:createWithSystemFont(loadtypeStr[1], "Arial", 12);
|
||||
local filePath = filename
|
||||
layer.rootNode = nil
|
||||
function layer:defaultPlay()end
|
||||
|
||||
local loadFileChangeHelper = function(filename)
|
||||
if filename ~= nil then
|
||||
if isCsbLoad then
|
||||
return filename .. ".csb"
|
||||
else
|
||||
return filename .. ".json"
|
||||
end
|
||||
end
|
||||
|
||||
return filename
|
||||
end
|
||||
|
||||
local changeLoadTypeCallback = function(sender)
|
||||
isCsbLoad = not isCsbLoad
|
||||
loadtypelb:setString(loadtypeStr[isCsbLoad == false and 1 or 2])
|
||||
local file = loadFileChangeHelper(filePath)
|
||||
|
||||
if layer.rootNode ~= nil then
|
||||
layer:removeChild(layer.rootNode)
|
||||
layer.rootNode = SceneReader:getInstance():createNodeWithSceneFile(file)
|
||||
layer:addChild(layer.rootNode, 0, 1)
|
||||
layer:defaultPlay()
|
||||
end
|
||||
end
|
||||
|
||||
function layer:enter()
|
||||
layer.rootNode = SceneReader:getInstance():createNodeWithSceneFile(loadFileChangeHelper(filePath))
|
||||
layer:addChild(layer.rootNode, 0, 1)
|
||||
layer:defaultPlay()
|
||||
end
|
||||
|
||||
function layer:exit()
|
||||
ccs.ArmatureDataManager:destroyInstance()
|
||||
ccs.SceneReader:destroyInstance()
|
||||
ccs.ActionManagerEx:destroyInstance()
|
||||
ccs.GUIReader:destroyInstance()
|
||||
end
|
||||
|
||||
local function onNodeEvent(event)
|
||||
if "enter" == event then
|
||||
layer:enter()
|
||||
elseif "exit" == event then
|
||||
layer:exit()
|
||||
end
|
||||
end
|
||||
layer:registerScriptHandler(onNodeEvent)
|
||||
|
||||
local itemlb = cc.MenuItemLabel:create(loadtypelb)
|
||||
itemlb:registerScriptTapHandler(changeLoadTypeCallback)
|
||||
local loadtypemenu = cc.Menu:create(itemlb)
|
||||
loadtypemenu:setPosition(cc.p(VisibleRect:rightTop().x -50,VisibleRect:rightTop().y -20));
|
||||
layer:addChild(loadtypemenu,100);
|
||||
|
||||
Helper.initWithLayer(layer)
|
||||
Helper.titleLabel:setString("SceneReader Test LoadSceneEditorFile")
|
||||
return layer
|
||||
end
|
||||
|
||||
function LoadSceneEdtiorFileTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/LoadSceneEdtiorFileTest/FishJoy2")
|
||||
Helper.titleLabel:setString("loadSceneEdtiorFile Test")
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function SpriteComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/SpriteComponentTest/SpriteComponentTest")
|
||||
Helper.titleLabel:setString("Sprite Component Test")
|
||||
|
||||
function layer:defaultPlay()
|
||||
layer.rootNode:getChildByTag(10003):getComponent("CCSprite"):getNode():runAction(cc.Blink:create(2, 10));
|
||||
layer.rootNode:getChildByTag(10004):getComponent("CCSprite"):getNode():runAction(cc.Blink:create(2, 5));
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function ArmatureComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/ArmatureComponentTest/ArmatureComponentTest")
|
||||
Helper.titleLabel:setString("Armature Component Test")
|
||||
|
||||
function layer:defaultPlay()
|
||||
layer.rootNode:getChildByTag(10007):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
layer.rootNode:getChildByTag(10008):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function UIComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/UIComponentTest/UIComponentTest")
|
||||
Helper.titleLabel:setString("UI Component Test")
|
||||
|
||||
local function touchEvent(sender,eventType)
|
||||
if eventType == ccui.TouchEventType.began then
|
||||
layer.rootNode:getChildByTag(10010):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
layer.rootNode:getChildByTag(10011):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
|
||||
end
|
||||
end
|
||||
|
||||
function layer:defaultPlay()
|
||||
local render = layer.rootNode:getChildByTag(10025):getComponent("GUIComponent")
|
||||
local widget = render:getNode()
|
||||
local button = widget:getChildByName("Button_156")
|
||||
button:addTouchEventListener(touchEvent)
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function TmxMapComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/TmxMapComponentTest/TmxMapComponentTest")
|
||||
Helper.titleLabel:setString("TmxMap Component Test")
|
||||
|
||||
function layer:defaultPlay()
|
||||
local render = layer.rootNode:getChildByTag(10015):getComponent("CCTMXTiledMap")
|
||||
|
||||
local skewTo = cc.SkewTo:create(2, 0, 2);
|
||||
local rotateTo = cc.RotateTo:create(2, 61);
|
||||
local scaleTo = cc.ScaleTo:create(2, -0.44, 0.47);
|
||||
local scaleBack = cc.ScaleTo:create(2, 1, 1);
|
||||
local rotateBack = cc.RotateTo:create(2, 0);
|
||||
local skewBack = cc.SkewTo:create(2, 0, 0);
|
||||
render:getNode():runAction(cc.Sequence:create(skewTo, skewBack));
|
||||
render:getNode():runAction(cc.Sequence:create(rotateTo, rotateBack));
|
||||
render:getNode():runAction(cc.Sequence:create(scaleTo, scaleBack));
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function ParticleComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/ParticleComponentTest/ParticleComponentTest")
|
||||
Helper.titleLabel:setString("Particle Component Test")
|
||||
|
||||
function layer:defaultPlay()
|
||||
local render = layer.rootNode:getChildByTag(10020):getComponent("CCParticleSystemQuad")
|
||||
|
||||
local action = cc.JumpBy:create(5, cc.p(-500,0), 50, 4);
|
||||
render:getNode():runAction(cc.Sequence:create(action, action:reverse()))
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function EffectComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/EffectComponentTest/EffectComponentTest")
|
||||
Helper.titleLabel:setString("Effect Component Test")
|
||||
|
||||
local animationEvent = function(armature,movementType,movementID)
|
||||
if movementType == ccs.MovementEventType.loopComplete then
|
||||
if movementID == "Fire" then
|
||||
layer.rootNode:getChildByTag(10015):getComponent("CCComAudio"):playEffect()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function layer:defaultPlay()
|
||||
local render = layer.rootNode:getChildByTag(10015):getComponent("CCArmature")
|
||||
|
||||
render:getNode():getAnimation():setMovementEventCallFunc(animationEvent);
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function BackgroundComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/BackgroundComponentTest/BackgroundComponentTest")
|
||||
Helper.titleLabel:setString("Background Component Test")
|
||||
|
||||
function layer:defaultPlay()
|
||||
layer.rootNode:getComponent("CCBackgroundAudio"):playBackgroundMusic();
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function AttributeComponentTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/AttributeComponentTest/AttributeComponentTest")
|
||||
Helper.titleLabel:setString("Attribute Component Test")
|
||||
|
||||
function layer:defaultPlay()
|
||||
local attribute = layer.rootNode:getChildByTag(10015):getComponent("CCComAttribute")
|
||||
cclog("Name: " .. attribute:getString("name") .. ", HP: " .. attribute:getFloat("maxHP") .. ", MP: " .. attribute:getFloat("maxMP"))
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function TriggerTest()
|
||||
local layer = SceneEditorTestLayer("scenetest/TriggerTest/TriggerTest")
|
||||
Helper.titleLabel:setString("Trigger Test")
|
||||
|
||||
local function onTouchBegan(touch, event)
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHBEGAN)
|
||||
end
|
||||
local function onTouchMoved(touch, event)
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHMOVED)
|
||||
end
|
||||
local function onTouchEnded(touch, event)
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHENDED)
|
||||
end
|
||||
local function onTouchCancelled(touch, event)
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHCANCELLED)
|
||||
end
|
||||
|
||||
|
||||
local touchListener = cc.EventListenerTouchOneByOne:create()
|
||||
touchListener:setSwallowTouches(true)
|
||||
touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN)
|
||||
touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED)
|
||||
touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED)
|
||||
touchListener:registerScriptHandler(onTouchCancelled, cc.Handler.EVENT_TOUCH_CANCELLED)
|
||||
local eventDispatcher = layer:getEventDispatcher()
|
||||
eventDispatcher:addEventListenerWithFixedPriority(touchListener, 1)
|
||||
|
||||
|
||||
local function gameLogic(dt)
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_UPDATESCENE)
|
||||
end
|
||||
|
||||
local layerExit = layer.exit
|
||||
function layer:exit()
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
|
||||
layer:unschedule(gameLogic)
|
||||
eventDispatcher:removeEventListener(touchListener)
|
||||
layerExit(layer)
|
||||
end
|
||||
|
||||
schedule(layer,gameLogic)
|
||||
|
||||
function layer:defaultPlay()
|
||||
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE);
|
||||
end
|
||||
|
||||
return layer
|
||||
end
|
||||
|
||||
function runStudioSceneTest()
|
||||
local scene = cc.Scene:create()
|
||||
|
||||
Helper.createFunctionTable = {
|
||||
LoadSceneEdtiorFileTest,
|
||||
SpriteComponentTest,
|
||||
ArmatureComponentTest,
|
||||
UIComponentTest,
|
||||
TmxMapComponentTest,
|
||||
ParticleComponentTest,
|
||||
EffectComponentTest,
|
||||
BackgroundComponentTest,
|
||||
AttributeComponentTest,
|
||||
TriggerTest,
|
||||
}
|
||||
|
||||
scene:addChild(Helper.createFunctionTable[1]())
|
||||
scene:addChild(CreateBackMenuItem())
|
||||
return scene
|
||||
end
|
|
@ -1012,39 +1012,37 @@ local function TMXOrthoFlipRunTimeTest()
|
|||
map:runAction(action)
|
||||
local function flipIt(dt)
|
||||
|
||||
-- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap")
|
||||
-- local layer = map:getLayer("Layer 0")
|
||||
local map = ret:getChildByTag(kTagTileMap)
|
||||
local layer = map:getLayer("Layer 0")
|
||||
|
||||
local tileCoord = cc.p(1, 10)
|
||||
local flags = 0
|
||||
local GID, flags = layer:getTileGIDAt(tileCoord, flags)
|
||||
if 0 ~= bit._and(flags, cc.TMX_TILE_VERTICAL_FLAG) then
|
||||
flags = bit._and(flags, bit._not(cc.TMX_TILE_VERTICAL_FLAG))
|
||||
else
|
||||
flags = bit._or(flags, cc.TMX_TILE_VERTICAL_FLAG)
|
||||
end
|
||||
layer:setTileGID(GID, tileCoord, flags)
|
||||
|
||||
-- --blue diamond
|
||||
-- local tileCoord = cc.p(1,10)
|
||||
-- local flags = 0
|
||||
-- local GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
|
||||
-- -- Vertical
|
||||
-- if( flags & kcc.TMXTileVerticalFlag )
|
||||
-- flags &= ~kcc.TMXTileVerticalFlag
|
||||
-- else
|
||||
-- flags |= kcc.TMXTileVerticalFlag
|
||||
-- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags)
|
||||
tileCoord = cc.p(1,8)
|
||||
GID, flags = layer:getTileGIDAt(tileCoord, flags)
|
||||
if 0 ~= bit._and(flags, cc.TMX_TILE_VERTICAL_FLAG) then
|
||||
flags = bit._and(flags, bit._not(cc.TMX_TILE_VERTICAL_FLAG))
|
||||
else
|
||||
flags = bit._or(flags, cc.TMX_TILE_VERTICAL_FLAG)
|
||||
end
|
||||
layer:setTileGID(GID ,tileCoord, flags)
|
||||
|
||||
|
||||
-- tileCoord = cc.p(1,8)
|
||||
-- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
|
||||
-- -- Vertical
|
||||
-- if( flags & kcc.TMXTileVerticalFlag )
|
||||
-- flags &= ~kcc.TMXTileVerticalFlag
|
||||
-- else
|
||||
-- flags |= kcc.TMXTileVerticalFlag
|
||||
-- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags)
|
||||
|
||||
|
||||
-- tileCoord = cc.p(2,8)
|
||||
-- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
|
||||
-- -- Horizontal
|
||||
-- if( flags & kcc.TMXTileHorizontalFlag )
|
||||
-- flags &= ~kcc.TMXTileHorizontalFlag
|
||||
-- else
|
||||
-- flags |= kcc.TMXTileHorizontalFlag
|
||||
-- layer:setTileGID(GID, tileCoord, (ccTMXTileFlags)flags)
|
||||
tileCoord = cc.p(2,8)
|
||||
GID, flags = layer:getTileGIDAt(tileCoord, flags)
|
||||
-- Horizontal
|
||||
if 0~= bit._and(flags, cc.TMX_TILE_HORIZONTAL_FLAG) then
|
||||
flags = bit._and(flags, bit._not(cc.TMX_TILE_HORIZONTAL_FLAG))
|
||||
else
|
||||
flags = bit._or(flags, cc.TMX_TILE_HORIZONTAL_FLAG)
|
||||
end
|
||||
layer:setTileGID(GID, tileCoord, flags)
|
||||
end
|
||||
local schedulerEntry = nil
|
||||
local function onNodeEvent(event)
|
||||
|
@ -1054,6 +1052,9 @@ local function TMXOrthoFlipRunTimeTest()
|
|||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||
end
|
||||
end
|
||||
|
||||
ret:registerScriptHandler(onNodeEvent)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ local vertDefaultSource = "\n".."\n" ..
|
|||
" v_texCoord = a_texCoord;\n" ..
|
||||
"} \n"
|
||||
|
||||
local scaleFactor = cc.Director:getInstance():getContentScaleFactor()
|
||||
|
||||
local function OpenGLTestMainLayer()
|
||||
local kItemTagBasic = 1000
|
||||
local testCount = 16
|
||||
|
@ -231,6 +233,8 @@ local function OpenGLTestMainLayer()
|
|||
time = 0
|
||||
majorLayer:addChild(glNode,-10)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor)
|
||||
glNode:getGLProgramState():setUniformVec2("center", center)
|
||||
return majorLayer
|
||||
end
|
||||
|
||||
|
@ -272,6 +276,8 @@ local function OpenGLTestMainLayer()
|
|||
time = 0
|
||||
mandelbrotLayer:addChild(glNode,-10)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor)
|
||||
glNode:getGLProgramState():setUniformVec2("center", center)
|
||||
return mandelbrotLayer
|
||||
end
|
||||
|
||||
|
@ -314,6 +320,8 @@ local function OpenGLTestMainLayer()
|
|||
time = 0
|
||||
heartLayer:addChild(glNode,-10)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor)
|
||||
glNode:getGLProgramState():setUniformVec2("center", center)
|
||||
return heartLayer
|
||||
end
|
||||
|
||||
|
@ -357,6 +365,8 @@ local function OpenGLTestMainLayer()
|
|||
time = 0
|
||||
plasmaLayer:addChild(glNode,-10)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor)
|
||||
glNode:getGLProgramState():setUniformVec2("center", center)
|
||||
return plasmaLayer
|
||||
end
|
||||
|
||||
|
@ -399,6 +409,8 @@ local function OpenGLTestMainLayer()
|
|||
time = 0
|
||||
flowerLayer:addChild(glNode,-10)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor)
|
||||
glNode:getGLProgramState():setUniformVec2("center", center)
|
||||
return flowerLayer
|
||||
end
|
||||
|
||||
|
@ -441,6 +453,8 @@ local function OpenGLTestMainLayer()
|
|||
time = 0
|
||||
juliaLayer:addChild(glNode,-10)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
local center = cc.p( size.width / 2 * scaleFactor, size.height / 2 * scaleFactor)
|
||||
glNode:getGLProgramState():setUniformVec2("center", center)
|
||||
return juliaLayer
|
||||
end
|
||||
|
||||
|
@ -545,7 +559,7 @@ local function OpenGLTestMainLayer()
|
|||
shader:setUniformsForBuiltins(transform)
|
||||
|
||||
gl.bindTexture(gl.TEXTURE_2D, texture.texture_id)
|
||||
gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_TEX_COORDS or cc.VERTEX_ATTRIB_FLAG_POSITION)
|
||||
gl.glEnableVertexAttribs(bit._or(cc.VERTEX_ATTRIB_FLAG_TEX_COORDS, cc.VERTEX_ATTRIB_FLAG_POSITION))
|
||||
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer.buffer_id)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION,2,gl.FLOAT,false,0,0)
|
||||
|
|
|
@ -16,89 +16,6 @@ local function range(from, to, step)
|
|||
end, nil, from - step
|
||||
end
|
||||
|
||||
-- bit operation
|
||||
|
||||
bit = bit or {}
|
||||
bit.data32 = {}
|
||||
for i=1,32 do
|
||||
bit.data32[i]=2^(32-i)
|
||||
end
|
||||
|
||||
function bit._b2d(arg)
|
||||
local nr=0
|
||||
for i=1,32 do
|
||||
if arg[i] ==1 then
|
||||
nr=nr+bit.data32[i]
|
||||
end
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function bit._d2b(arg)
|
||||
arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1)
|
||||
local tr={}
|
||||
for i=1,32 do
|
||||
if arg >= bit.data32[i] then
|
||||
tr[i]=1
|
||||
arg=arg-bit.data32[i]
|
||||
else
|
||||
tr[i]=0
|
||||
end
|
||||
end
|
||||
return tr
|
||||
end
|
||||
|
||||
function bit._and(a,b)
|
||||
local op1=bit._d2b(a)
|
||||
local op2=bit._d2b(b)
|
||||
local r={}
|
||||
|
||||
for i=1,32 do
|
||||
if op1[i]==1 and op2[i]==1 then
|
||||
r[i]=1
|
||||
else
|
||||
r[i]=0
|
||||
end
|
||||
end
|
||||
return bit._b2d(r)
|
||||
|
||||
end
|
||||
|
||||
function bit._rshift(a,n)
|
||||
local op1=bit._d2b(a)
|
||||
n = n <= 32 and n or 32
|
||||
n = n >= 0 and n or 0
|
||||
|
||||
for i=32, n+1, -1 do
|
||||
op1[i] = op1[i-n]
|
||||
end
|
||||
for i=1, n do
|
||||
op1[i] = 0
|
||||
end
|
||||
|
||||
return bit._b2d(op1)
|
||||
end
|
||||
|
||||
function bit._not(a)
|
||||
local op1=bit._d2b(a)
|
||||
local r={}
|
||||
|
||||
for i=1,32 do
|
||||
if op1[i]==1 then
|
||||
r[i]=0
|
||||
else
|
||||
r[i]=1
|
||||
end
|
||||
end
|
||||
return bit._b2d(r)
|
||||
end
|
||||
|
||||
bit.band = bit.band or bit._and
|
||||
bit.rshift = bit.rshift or bit._rshift
|
||||
bit.bnot = bit.bnot or bit._not
|
||||
|
||||
-- bit operation end
|
||||
|
||||
local function initWithLayer(layer, callback)
|
||||
curLayer = layer
|
||||
layer.spriteTexture = cc.SpriteBatchNode:create("Images/grossini_dance_atlas.png", 100):getTexture()
|
||||
|
|
|
@ -1001,14 +1001,15 @@ local function TextureAsync()
|
|||
cc.Director:getInstance():getTextureCache():addImageAsync("Images/background.png", imageLoaded)
|
||||
cc.Director:getInstance():getTextureCache():addImageAsync("Images/atlastest.png", imageLoaded)
|
||||
cc.Director:getInstance():getTextureCache():addImageAsync("Images/grossini_dance_atlas.png",imageLoaded)
|
||||
|
||||
ret:unscheduleUpdate()
|
||||
end
|
||||
|
||||
local schedulerEntry = nil
|
||||
local function onNodeEvent(event)
|
||||
if event == "enter" then
|
||||
schedulerEntry = scheduler:scheduleScriptFunc(loadImages, 1.0, false)
|
||||
ret:scheduleUpdateWithPriorityLua(loadImages,0)
|
||||
elseif event == "exit" then
|
||||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||
ret:unscheduleUpdate()
|
||||
cc.Director:getInstance():getTextureCache():removeAllTextures()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1106,41 +1106,40 @@ local function TMXOrthoFlipRunTimeTest()
|
|||
local action = cc.ScaleBy:create(2, 0.5)
|
||||
map:runAction(action)
|
||||
local function flipIt(dt)
|
||||
local map = ret:getChildByTag(kTagTileMap)
|
||||
local layer = map:getLayer("Layer 0")
|
||||
|
||||
-- local map = tolua.cast(ret:getChildByTag(kTagTileMap), "TMXTiledMap")
|
||||
-- local layer = map:getLayer("Layer 0")
|
||||
local tileCoord = cc.p(1, 10)
|
||||
local flags = 0
|
||||
local GID, flags = layer:getTileGIDAt(tileCoord, flags)
|
||||
|
||||
-- --blue diamond
|
||||
-- local tileCoord = cc.p(1,10)
|
||||
-- local flags = 0
|
||||
-- local GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
|
||||
-- -- Vertical
|
||||
-- if( flags & kcc.TMXTileVerticalFlag )
|
||||
-- flags &= ~kcc.TMXTileVerticalFlag
|
||||
-- else
|
||||
-- flags |= kcc.TMXTileVerticalFlag
|
||||
-- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags)
|
||||
if 0 ~= bit._and(flags, cc.TMX_TILE_VERTICAL_FLAG) then
|
||||
flags = bit._and(flags, bit._not(cc.TMX_TILE_VERTICAL_FLAG))
|
||||
else
|
||||
flags = bit._or(flags, cc.TMX_TILE_VERTICAL_FLAG)
|
||||
end
|
||||
layer:setTileGID(GID, tileCoord, flags)
|
||||
|
||||
tileCoord = cc.p(1,8)
|
||||
GID, flags = layer:getTileGIDAt(tileCoord, flags)
|
||||
if 0 ~= bit._and(flags, cc.TMX_TILE_VERTICAL_FLAG) then
|
||||
flags = bit._and(flags, bit._not(cc.TMX_TILE_VERTICAL_FLAG))
|
||||
else
|
||||
flags = bit._or(flags, cc.TMX_TILE_VERTICAL_FLAG)
|
||||
end
|
||||
layer:setTileGID(GID ,tileCoord, flags)
|
||||
|
||||
-- tileCoord = cc.p(1,8)
|
||||
-- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
|
||||
-- -- Vertical
|
||||
-- if( flags & kcc.TMXTileVerticalFlag )
|
||||
-- flags &= ~kcc.TMXTileVerticalFlag
|
||||
-- else
|
||||
-- flags |= kcc.TMXTileVerticalFlag
|
||||
-- layer:setTileGID(GID ,tileCoord, (ccTMXTileFlags)flags)
|
||||
|
||||
|
||||
-- tileCoord = cc.p(2,8)
|
||||
-- GID = layer:getTileGIDAt(tileCoord, (ccTMXTileFlags*)&flags)
|
||||
-- -- Horizontal
|
||||
-- if( flags & kcc.TMXTileHorizontalFlag )
|
||||
-- flags &= ~kcc.TMXTileHorizontalFlag
|
||||
-- else
|
||||
-- flags |= kcc.TMXTileHorizontalFlag
|
||||
-- layer:setTileGID(GID, tileCoord, (ccTMXTileFlags)flags)
|
||||
tileCoord = cc.p(2,8)
|
||||
GID, flags = layer:getTileGIDAt(tileCoord, flags)
|
||||
-- Horizontal
|
||||
if 0~= bit._and(flags, cc.TMX_TILE_HORIZONTAL_FLAG) then
|
||||
flags = bit._and(flags, bit._not(cc.TMX_TILE_HORIZONTAL_FLAG))
|
||||
else
|
||||
flags = bit._or(flags, cc.TMX_TILE_HORIZONTAL_FLAG)
|
||||
end
|
||||
layer:setTileGID(GID, tileCoord, flags)
|
||||
end
|
||||
|
||||
local schedulerEntry = nil
|
||||
local function onNodeEvent(event)
|
||||
if event == "enter" then
|
||||
|
@ -1149,6 +1148,9 @@ local function TMXOrthoFlipRunTimeTest()
|
|||
scheduler:unscheduleScriptEntry(schedulerEntry)
|
||||
end
|
||||
end
|
||||
|
||||
ret:registerScriptHandler(onNodeEvent)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ require "Opengl"
|
|||
require "OpenglConstants"
|
||||
require "StudioConstants"
|
||||
require "GuiConstants"
|
||||
require "bitExtend"
|
||||
require "src/helper"
|
||||
require "src/testResource"
|
||||
require "src/VisibleRect"
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 79ba55769e56d4119b0968bbbaae0ce2390e0a2a
|
||||
Subproject commit 55c1733c8b522573994dae1c6787189addef8651
|
Loading…
Reference in New Issue