mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/super626/cocos2d-x into v3
This commit is contained in:
commit
7b27bd0e72
|
@ -25,6 +25,7 @@ cocos2d-x-3.3-beta1
|
||||||
[FIX] Node: unscheduleAllSelectors() deprecated in favor of unscheudleAllCallbacks()
|
[FIX] Node: unscheduleAllSelectors() deprecated in favor of unscheudleAllCallbacks()
|
||||||
[FIX] Node: crashed if remove/add child too quickly when using integrated physics
|
[FIX] Node: crashed if remove/add child too quickly when using integrated physics
|
||||||
[FIX] TextFieldTTF: will get wrong characters if using Chinese input method on WP8
|
[FIX] TextFieldTTF: will get wrong characters if using Chinese input method on WP8
|
||||||
|
[FIX] UI: Button: button remains gray when releasing it, this issue only happened if enable scale9 and only has one texture
|
||||||
|
|
||||||
cocos2d-x-3.3-beta0 Sep.20 2014
|
cocos2d-x-3.3-beta0 Sep.20 2014
|
||||||
[NEW] 3d: added `BillBoard`
|
[NEW] 3d: added `BillBoard`
|
||||||
|
|
|
@ -115,7 +115,11 @@ void ActionManagerEx::initWithDictionary(const char* jsonName,const rapidjson::V
|
||||||
|
|
||||||
ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName)
|
ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* actionName)
|
||||||
{
|
{
|
||||||
auto iterator = _actionDic.find(jsonName);
|
std::string path = jsonName;
|
||||||
|
ssize_t pos = path.find_last_of("/");
|
||||||
|
std::string fileName = path.substr(pos+1,path.length());
|
||||||
|
CCLOG("find filename == %s",fileName.c_str());
|
||||||
|
auto iterator = _actionDic.find(fileName);
|
||||||
if (iterator == _actionDic.end())
|
if (iterator == _actionDic.end())
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -226,7 +226,50 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
|
|
||||||
class cocos2dEGLConfigChooser implements GLSurfaceView.EGLConfigChooser
|
class cocos2dEGLConfigChooser implements GLSurfaceView.EGLConfigChooser
|
||||||
{
|
{
|
||||||
public int[] attribs;
|
protected int[] configAttribs;
|
||||||
|
public cocos2dEGLConfigChooser(int redSize, int greenSize, int blueSize, int alphaSize, int depthSize, int stencilSize)
|
||||||
|
{
|
||||||
|
configAttribs = new int[] {redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize};
|
||||||
|
}
|
||||||
|
public cocos2dEGLConfigChooser(int[] attribs)
|
||||||
|
{
|
||||||
|
configAttribs = attribs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EGLConfig selectConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs, int[] attribs)
|
||||||
|
{
|
||||||
|
for (EGLConfig config : configs) {
|
||||||
|
int d = findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_DEPTH_SIZE, 0);
|
||||||
|
int s = findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_STENCIL_SIZE, 0);
|
||||||
|
if ((d >= attribs[4]) && (s >= attribs[5])) {
|
||||||
|
int r = findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_RED_SIZE, 0);
|
||||||
|
int g = findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_GREEN_SIZE, 0);
|
||||||
|
int b = findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_BLUE_SIZE, 0);
|
||||||
|
int a = findConfigAttrib(egl, display, config,
|
||||||
|
EGL10.EGL_ALPHA_SIZE, 0);
|
||||||
|
if ((r >= attribs[0]) && (g >= attribs[1])
|
||||||
|
&& (b >= attribs[2]) && (a >= attribs[3])) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int findConfigAttrib(EGL10 egl, EGLDisplay display,
|
||||||
|
EGLConfig config, int attribute, int defaultValue) {
|
||||||
|
int[] value = new int[1];
|
||||||
|
if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
|
||||||
|
return value[0];
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
|
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
|
||||||
{
|
{
|
||||||
|
@ -235,12 +278,13 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
{
|
{
|
||||||
EGLConfig[] configs = new EGLConfig[numConfigs[0]];
|
EGLConfig[] configs = new EGLConfig[numConfigs[0]];
|
||||||
int[] EGLattribs = {
|
int[] EGLattribs = {
|
||||||
EGL10.EGL_RED_SIZE, attribs[0],
|
EGL10.EGL_RED_SIZE, configAttribs[0],
|
||||||
EGL10.EGL_GREEN_SIZE, attribs[1],
|
EGL10.EGL_GREEN_SIZE, configAttribs[1],
|
||||||
EGL10.EGL_BLUE_SIZE, attribs[2],
|
EGL10.EGL_BLUE_SIZE, configAttribs[2],
|
||||||
EGL10.EGL_ALPHA_SIZE, attribs[3],
|
EGL10.EGL_ALPHA_SIZE, configAttribs[3],
|
||||||
EGL10.EGL_DEPTH_SIZE, attribs[4],
|
EGL10.EGL_DEPTH_SIZE, configAttribs[4],
|
||||||
EGL10.EGL_STENCIL_SIZE,attribs[5],
|
EGL10.EGL_STENCIL_SIZE,configAttribs[5],
|
||||||
|
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||||
EGL10.EGL_NONE
|
EGL10.EGL_NONE
|
||||||
};
|
};
|
||||||
int[] choosedConfigNum = new int[1];
|
int[] choosedConfigNum = new int[1];
|
||||||
|
@ -248,7 +292,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
egl.eglChooseConfig(display, EGLattribs, configs, numConfigs[0], choosedConfigNum);
|
egl.eglChooseConfig(display, EGLattribs, configs, numConfigs[0], choosedConfigNum);
|
||||||
if(choosedConfigNum[0]>0)
|
if(choosedConfigNum[0]>0)
|
||||||
{
|
{
|
||||||
return configs[0];
|
return selectConfig(egl, display, configs, configAttribs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -259,6 +303,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
EGL10.EGL_ALPHA_SIZE, 0,
|
EGL10.EGL_ALPHA_SIZE, 0,
|
||||||
EGL10.EGL_DEPTH_SIZE, 0,
|
EGL10.EGL_DEPTH_SIZE, 0,
|
||||||
EGL10.EGL_STENCIL_SIZE,0,
|
EGL10.EGL_STENCIL_SIZE,0,
|
||||||
|
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||||
EGL10.EGL_NONE
|
EGL10.EGL_NONE
|
||||||
};
|
};
|
||||||
int[] defaultEGLattribsAlpha = {
|
int[] defaultEGLattribsAlpha = {
|
||||||
|
@ -268,17 +313,24 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
EGL10.EGL_ALPHA_SIZE, 4,
|
EGL10.EGL_ALPHA_SIZE, 4,
|
||||||
EGL10.EGL_DEPTH_SIZE, 0,
|
EGL10.EGL_DEPTH_SIZE, 0,
|
||||||
EGL10.EGL_STENCIL_SIZE,0,
|
EGL10.EGL_STENCIL_SIZE,0,
|
||||||
|
EGL10.EGL_RENDERABLE_TYPE, 4, //EGL_OPENGL_ES2_BIT
|
||||||
EGL10.EGL_NONE
|
EGL10.EGL_NONE
|
||||||
};
|
};
|
||||||
|
int[] attribs = null;
|
||||||
//choose one can use
|
//choose one can use
|
||||||
if(this.attribs[3] == 0)
|
if(this.configAttribs[3] == 0)
|
||||||
|
{
|
||||||
egl.eglChooseConfig(display, defaultEGLattribs, configs, numConfigs[0], choosedConfigNum);
|
egl.eglChooseConfig(display, defaultEGLattribs, configs, numConfigs[0], choosedConfigNum);
|
||||||
|
attribs = new int[]{5,6,5,0,0,0};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
egl.eglChooseConfig(display, defaultEGLattribsAlpha, configs, numConfigs[0], choosedConfigNum);
|
egl.eglChooseConfig(display, defaultEGLattribsAlpha, configs, numConfigs[0], choosedConfigNum);
|
||||||
|
attribs = new int[]{4,4,4,4,0,0};
|
||||||
|
}
|
||||||
if(choosedConfigNum[0] > 0)
|
if(choosedConfigNum[0] > 0)
|
||||||
{
|
{
|
||||||
Log.w(DEVICE_POLICY_SERVICE, "The EGLConfig can not be used for rendering, use a default one");
|
return selectConfig(egl, display, configs, attribs);
|
||||||
return configs[0];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -290,9 +342,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
|
Log.e(DEVICE_POLICY_SERVICE, "Can not select an EGLConfig for rendering.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
cocos2dEGLConfigChooser chooser = new cocos2dEGLConfigChooser();
|
cocos2dEGLConfigChooser chooser = new cocos2dEGLConfigChooser(this.glContextAttrs);
|
||||||
chooser.attribs = this.glContextAttrs;
|
|
||||||
glSurfaceView.setEGLConfigChooser(chooser);
|
glSurfaceView.setEGLConfigChooser(chooser);
|
||||||
|
|
||||||
return glSurfaceView;
|
return glSurfaceView;
|
||||||
|
|
|
@ -373,14 +373,22 @@ void Button::onPressStateChangedToNormal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (_scale9Enabled)
|
||||||
|
{
|
||||||
|
_buttonNormalRenderer->setColor(Color3B::WHITE);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
_buttonNormalRenderer->stopAllActions();
|
_buttonNormalRenderer->stopAllActions();
|
||||||
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
|
_buttonNormalRenderer->setScale(_normalTextureScaleXInSize, _normalTextureScaleYInSize);
|
||||||
|
|
||||||
_titleRenderer->stopAllActions();
|
_titleRenderer->stopAllActions();
|
||||||
_titleRenderer->setScaleX(_normalTextureScaleXInSize);
|
_titleRenderer->setScaleX(_normalTextureScaleXInSize);
|
||||||
_titleRenderer->setScaleY(_normalTextureScaleYInSize);
|
_titleRenderer->setScaleY(_normalTextureScaleYInSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Button::onPressStateChangedToPressed()
|
void Button::onPressStateChangedToPressed()
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-10
|
target=android-10
|
||||||
|
|
||||||
android.library.reference.1=../../../cocos/platform/android/java
|
android.library.reference.1=../cocos2d/cocos/platform/android/java
|
||||||
|
|
Loading…
Reference in New Issue