mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3
This commit is contained in:
commit
d69050399b
|
@ -133,6 +133,11 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
|
||||||
//CCLabelAtlas - Atlas generation
|
//CCLabelAtlas - Atlas generation
|
||||||
void LabelAtlas::updateAtlasValues()
|
void LabelAtlas::updateAtlasValues()
|
||||||
{
|
{
|
||||||
|
if(_itemsPerRow == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t n = _string.length();
|
ssize_t n = _string.length();
|
||||||
|
|
||||||
const unsigned char *s = (unsigned char*)_string.c_str();
|
const unsigned char *s = (unsigned char*)_string.c_str();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<PropertyGroup />
|
<PropertyGroup />
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(EngineRoot)cocos\platform\wp8;$(EngineRoot)cocos\platform\winrt;$(EngineRoot)\external\winrt-specific\angle\include;$(EngineRoot)\external\curl\include\wp8;$(EngineRoot)\external\winrt-specific;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external;$(EngineRoot)cocos\editor-support;$(EngineRoot);$(EngineRoot)external\ConvertUTF;$(EngineRoot)external\wp8-specific\zlib\include;$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_VARIADIC_MAX=10;NOMINMAX;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<CompileAsWinRT>true</CompileAsWinRT>
|
<CompileAsWinRT>true</CompileAsWinRT>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||||
|
|
|
@ -47,18 +47,19 @@ public:
|
||||||
auto iter = std::find_if(Controller::s_allController.begin(), Controller::s_allController.end(), [&](Controller* controller){
|
auto iter = std::find_if(Controller::s_allController.begin(), Controller::s_allController.end(), [&](Controller* controller){
|
||||||
return (deviceName == controller->_deviceName) && (deviceId == controller->_deviceId);
|
return (deviceName == controller->_deviceName) && (deviceId == controller->_deviceId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onConnected(const std::string& deviceName, int deviceId)
|
static void onConnected(const std::string& deviceName, int deviceId)
|
||||||
{
|
{
|
||||||
// Check whether the controller is already connected.
|
// Check whether the controller is already connected.
|
||||||
log("onConnected %s,%d", deviceName.c_str(),deviceId);
|
CCLOG("onConnected %s,%d", deviceName.c_str(),deviceId);
|
||||||
|
|
||||||
auto iter = findController(deviceName, deviceId);
|
auto iter = findController(deviceName, deviceId);
|
||||||
if (iter != Controller::s_allController.end())
|
if (iter != Controller::s_allController.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
log("onConnected new device");
|
|
||||||
// It's a new controller being connected.
|
// It's a new controller being connected.
|
||||||
auto controller = new cocos2d::Controller();
|
auto controller = new cocos2d::Controller();
|
||||||
controller->_deviceId = deviceId;
|
controller->_deviceId = deviceId;
|
||||||
|
@ -70,11 +71,11 @@ public:
|
||||||
|
|
||||||
static void onDisconnected(const std::string& deviceName, int deviceId)
|
static void onDisconnected(const std::string& deviceName, int deviceId)
|
||||||
{
|
{
|
||||||
log("onDisconnected %s,%d", deviceName.c_str(),deviceId);
|
CCLOG("onDisconnected %s,%d", deviceName.c_str(),deviceId);
|
||||||
|
|
||||||
auto iter = findController(deviceName, deviceId);
|
auto iter = findController(deviceName, deviceId);
|
||||||
if (iter == Controller::s_allController.end())
|
if (iter == Controller::s_allController.end())
|
||||||
{
|
{
|
||||||
log("Could not find the controller!");
|
|
||||||
CCLOGERROR("Could not find the controller!");
|
CCLOGERROR("Could not find the controller!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -85,11 +86,10 @@ public:
|
||||||
|
|
||||||
static void onButtonEvent(const std::string& deviceName, int deviceId, int keyCode, bool isPressed, float value, bool isAnalog)
|
static void onButtonEvent(const std::string& deviceName, int deviceId, int keyCode, bool isPressed, float value, bool isAnalog)
|
||||||
{
|
{
|
||||||
log("onButtonEvent %s,%d", deviceName.c_str(),deviceId);
|
|
||||||
auto iter = findController(deviceName, deviceId);
|
auto iter = findController(deviceName, deviceId);
|
||||||
if (iter == Controller::s_allController.end())
|
if (iter == Controller::s_allController.end())
|
||||||
{
|
{
|
||||||
log("onButtonEvent new connect");
|
CCLOG("onButtonEvent:connect new controller.");
|
||||||
onConnected(deviceName, deviceId);
|
onConnected(deviceName, deviceId);
|
||||||
iter = findController(deviceName, deviceId);
|
iter = findController(deviceName, deviceId);
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ public:
|
||||||
auto iter = findController(deviceName, deviceId);
|
auto iter = findController(deviceName, deviceId);
|
||||||
if (iter == Controller::s_allController.end())
|
if (iter == Controller::s_allController.end())
|
||||||
{
|
{
|
||||||
|
CCLOG("onAxisEvent:connect new controller.");
|
||||||
onConnected(deviceName, deviceId);
|
onConnected(deviceName, deviceId);
|
||||||
iter = findController(deviceName, deviceId);
|
iter = findController(deviceName, deviceId);
|
||||||
}
|
}
|
||||||
|
@ -154,6 +155,16 @@ Controller::Controller()
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
|
||||||
|
{
|
||||||
|
JniMethodInfo t;
|
||||||
|
if (JniHelper::getStaticMethodInfo(t, "org/cocos2dx/lib/GameControllerHelper", "receiveExternalKeyEvent", "(IIZ)V")) {
|
||||||
|
|
||||||
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, _deviceId, externalKeyCode, receive);
|
||||||
|
t.env->DeleteLocalRef(t.classID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -311,6 +311,10 @@ bool Controller::isConnected() const
|
||||||
return _impl->_gcController.isAttachedToDevice == YES;
|
return _impl->_gcController.isAttachedToDevice == YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
|
||||||
|
|
|
@ -99,6 +99,15 @@ public:
|
||||||
|
|
||||||
const KeyStatus& getKeyStatus(int keyCode);
|
const KeyStatus& getKeyStatus(int keyCode);
|
||||||
|
|
||||||
|
/** Activate receives key event from external key. e.g. back,menu.
|
||||||
|
* Controller receives only standard key which contained within enum Key by default.
|
||||||
|
* @warning The API only work on the android platform for support diversified game controller.
|
||||||
|
*
|
||||||
|
* @param externalKeyCode external key code
|
||||||
|
* @param receive true if external key event on this controller should be receive, false otherwise.
|
||||||
|
*/
|
||||||
|
void receiveExternalKeyEvent(int externalKeyCode,bool receive);
|
||||||
|
|
||||||
void setTag(int tag) { _controllerTag = tag;}
|
void setTag(int tag) { _controllerTag = tag;}
|
||||||
int getTag() const { return _controllerTag;}
|
int getTag() const { return _controllerTag;}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
const char* cocos2dVersion()
|
const char* cocos2dVersion()
|
||||||
{
|
{
|
||||||
return "cocos2d-x 3.2alpha0";
|
return "cocos2d-x 3.2beta0";
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace cocostudio
|
||||||
|
|
||||||
Text* label = static_cast<Text*>(widget);
|
Text* label = static_cast<Text*>(widget);
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
std::string binaryFilePath = GUIReader::getInstance()->getFilePath();
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
for (int i = 0; i < cocoNode->GetChildNum(); ++i) {
|
||||||
|
@ -70,11 +70,7 @@ namespace cocostudio
|
||||||
label->setFontSize(valueToInt(value));
|
label->setFontSize(valueToInt(value));
|
||||||
}else if(key == P_FontName){
|
}else if(key == P_FontName){
|
||||||
std::string fontFilePath;
|
std::string fontFilePath;
|
||||||
if(FileUtils::getInstance()->isFileExist(value)){
|
fontFilePath = binaryFilePath.append(value);
|
||||||
fontFilePath = jsonPath.append(value);
|
|
||||||
}else{
|
|
||||||
fontFilePath = value;
|
|
||||||
}
|
|
||||||
label->setFontName(fontFilePath);
|
label->setFontName(fontFilePath);
|
||||||
}else if(key == P_AreaWidth){
|
}else if(key == P_AreaWidth){
|
||||||
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));
|
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));
|
||||||
|
|
|
@ -114,8 +114,10 @@ namespace cocostudio
|
||||||
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
|
void WidgetReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
|
||||||
{
|
{
|
||||||
|
|
||||||
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize,false));
|
bool ignoreSizeExsit = DICTOOL->checkObjectExist_json(options, P_IgnoreSize);
|
||||||
|
if (ignoreSizeExsit) {
|
||||||
|
widget->ignoreContentAdaptWithSize(DICTOOL->getBooleanValue_json(options, P_IgnoreSize));
|
||||||
|
}
|
||||||
|
|
||||||
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
|
widget->setSizeType((Widget::SizeType)DICTOOL->getIntValue_json(options, P_SizeType));
|
||||||
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
|
widget->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||||
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)external\wp8-specific\zlib\include;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;$(EngineRoot)external\tinyxml2;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PreprocessorDefinitions>WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WP8;_DEBUG;_LIB;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
|
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
|
|
@ -31,11 +31,9 @@ import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat.InputDeviceListene
|
||||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.InputDevice;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
|
||||||
|
|
||||||
public abstract class GameControllerActivity extends Cocos2dxActivity implements InputDeviceListener {
|
public abstract class GameControllerActivity extends Cocos2dxActivity implements InputDeviceListener {
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
@ -224,30 +222,11 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
|
||||||
return handled || super.dispatchGenericMotionEvent(event);
|
return handled || super.dispatchGenericMotionEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SparseArray<String> mGameController = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputDeviceAdded(int deviceId) {
|
public void onInputDeviceAdded(int deviceId) {
|
||||||
Log.d(TAG,"onInputDeviceAdded:" + deviceId);
|
Log.d(TAG,"onInputDeviceAdded:" + deviceId);
|
||||||
|
|
||||||
try {
|
mControllerHelper.onInputDeviceAdded(deviceId);
|
||||||
InputDevice device = InputDevice.getDevice(deviceId);
|
|
||||||
int deviceSource = device.getSources();
|
|
||||||
|
|
||||||
if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
|
||||||
|| ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
|
||||||
{
|
|
||||||
if (mGameController == null) {
|
|
||||||
mGameController = new SparseArray<String>();
|
|
||||||
}
|
|
||||||
String deviceName = device.getName();
|
|
||||||
mGameController.append(deviceId, deviceName);
|
|
||||||
GameControllerAdapter.onConnected(deviceName, deviceId);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* This is an unusual case. Input devices don't typically change, but they
|
* This is an unusual case. Input devices don't typically change, but they
|
||||||
|
@ -274,10 +253,7 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
|
||||||
public void onInputDeviceRemoved(int deviceId) {
|
public void onInputDeviceRemoved(int deviceId) {
|
||||||
Log.d(TAG,"onInputDeviceRemoved:" + deviceId);
|
Log.d(TAG,"onInputDeviceRemoved:" + deviceId);
|
||||||
|
|
||||||
if (mGameController != null && mGameController.get(deviceId) != null) {
|
mControllerHelper.onInputDeviceRemoved(deviceId);
|
||||||
GameControllerAdapter.onDisconnected(mGameController.get(deviceId), deviceId);
|
|
||||||
mGameController.delete(deviceId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -293,6 +269,8 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
|
||||||
if (mControllerOuya != null) {
|
if (mControllerOuya != null) {
|
||||||
mControllerOuya.onResume();
|
mControllerOuya.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mControllerHelper.gatherControllers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.cocos2dx.lib;
|
package org.cocos2dx.lib;
|
||||||
|
|
||||||
import android.util.Log;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
@ -53,7 +55,6 @@ public class GameControllerHelper {
|
||||||
|
|
||||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_START, GameControllerDelegate.BUTTON_START);
|
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_START, GameControllerDelegate.BUTTON_START);
|
||||||
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GameControllerDelegate.BUTTON_SELECT);
|
ControllerKeyMap.put(KeyEvent.KEYCODE_BUTTON_SELECT, GameControllerDelegate.BUTTON_SELECT);
|
||||||
//KEYCODE_BUTTON_MODE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float mOldLeftThumbstickX = 0.0f;
|
private float mOldLeftThumbstickX = 0.0f;
|
||||||
|
@ -76,68 +77,71 @@ public class GameControllerHelper {
|
||||||
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
||||||
{
|
{
|
||||||
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
int devicedId = event.getDeviceId();
|
int deviceId = event.getDeviceId();
|
||||||
String deviceName = event.getDevice().getName();
|
String deviceName = event.getDevice().getName();
|
||||||
|
if(mGameController.get(deviceId) == null){
|
||||||
|
mGameController.append(deviceId, deviceName);
|
||||||
|
}
|
||||||
|
|
||||||
float newAXIS_LX = event.getAxisValue(AXIS_X);
|
float newAXIS_LX = event.getAxisValue(AXIS_X);
|
||||||
if (Float.compare(newAXIS_LX , mOldLeftThumbstickX) != 0) {
|
if (Float.compare(newAXIS_LX , mOldLeftThumbstickX) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_X, newAXIS_LX, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, newAXIS_LX, true);
|
||||||
mOldLeftThumbstickX = newAXIS_LX;
|
mOldLeftThumbstickX = newAXIS_LX;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_LY = event.getAxisValue(AXIS_Y);
|
float newAXIS_LY = event.getAxisValue(AXIS_Y);
|
||||||
if (Float.compare(newAXIS_LY , mOldLeftThumbstickY) != 0) {
|
if (Float.compare(newAXIS_LY , mOldLeftThumbstickY) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newAXIS_LY, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newAXIS_LY, true);
|
||||||
mOldLeftThumbstickY = newAXIS_LY;
|
mOldLeftThumbstickY = newAXIS_LY;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_RX = event.getAxisValue(AXIS_Z);
|
float newAXIS_RX = event.getAxisValue(AXIS_Z);
|
||||||
if (Float.compare(newAXIS_RX , mOldRightThumbstickX) != 0) {
|
if (Float.compare(newAXIS_RX , mOldRightThumbstickX) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newAXIS_RX, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newAXIS_RX, true);
|
||||||
mOldRightThumbstickX = newAXIS_RX;
|
mOldRightThumbstickX = newAXIS_RX;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_RY = event.getAxisValue(AXIS_RZ);
|
float newAXIS_RY = event.getAxisValue(AXIS_RZ);
|
||||||
if (Float.compare(newAXIS_RY , mOldRightThumbstickY) != 0) {
|
if (Float.compare(newAXIS_RY , mOldRightThumbstickY) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newAXIS_RY, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newAXIS_RY, true);
|
||||||
mOldRightThumbstickY = newAXIS_RY;
|
mOldRightThumbstickY = newAXIS_RY;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_LTRIGGER = event.getAxisValue(AXIS_LTRIGGER);
|
float newAXIS_LTRIGGER = event.getAxisValue(AXIS_LTRIGGER);
|
||||||
if (Float.compare(newAXIS_LTRIGGER , mOldLeftTrigger) != 0) {
|
if (Float.compare(newAXIS_LTRIGGER , mOldLeftTrigger) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_LTRIGGER, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_LTRIGGER, true);
|
||||||
mOldLeftTrigger = newAXIS_LTRIGGER;
|
mOldLeftTrigger = newAXIS_LTRIGGER;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_RTRIGGER = event.getAxisValue(AXIS_RTRIGGER);
|
float newAXIS_RTRIGGER = event.getAxisValue(AXIS_RTRIGGER);
|
||||||
if (Float.compare(newAXIS_RTRIGGER , mOldRightTrigger) != 0) {
|
if (Float.compare(newAXIS_RTRIGGER , mOldRightTrigger) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_RTRIGGER, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_RTRIGGER, true);
|
||||||
mOldRightTrigger = newAXIS_RTRIGGER;
|
mOldRightTrigger = newAXIS_RTRIGGER;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_BRAKE = event.getAxisValue(AXIS_BRAKE);
|
float newAXIS_BRAKE = event.getAxisValue(AXIS_BRAKE);
|
||||||
if (Float.compare(newAXIS_BRAKE , mOldBrake) != 0) {
|
if (Float.compare(newAXIS_BRAKE , mOldBrake) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_BRAKE, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newAXIS_BRAKE, true);
|
||||||
mOldBrake = newAXIS_BRAKE;
|
mOldBrake = newAXIS_BRAKE;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_THROTTLE = event.getAxisValue(AXIS_THROTTLE);
|
float newAXIS_THROTTLE = event.getAxisValue(AXIS_THROTTLE);
|
||||||
if (Float.compare(newAXIS_THROTTLE , mOldThrottle) != 0) {
|
if (Float.compare(newAXIS_THROTTLE , mOldThrottle) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_THROTTLE, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_THROTTLE, true);
|
||||||
mOldThrottle = newAXIS_THROTTLE;
|
mOldThrottle = newAXIS_THROTTLE;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newAXIS_GAS = event.getAxisValue(AXIS_GAS);
|
float newAXIS_GAS = event.getAxisValue(AXIS_GAS);
|
||||||
if (Float.compare(newAXIS_GAS , mOldGas) != 0) {
|
if (Float.compare(newAXIS_GAS , mOldGas) != 0) {
|
||||||
GameControllerAdapter.onAxisEvent(deviceName, devicedId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_GAS, true);
|
GameControllerAdapter.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newAXIS_GAS, true);
|
||||||
mOldGas = newAXIS_GAS;
|
mOldGas = newAXIS_GAS;
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
@ -147,6 +151,8 @@ public class GameControllerHelper {
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static SparseArray<ArrayList<Integer>> mControllerExtendKey = new SparseArray<ArrayList<Integer>>();
|
||||||
|
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
|
|
||||||
|
@ -154,19 +160,96 @@ public class GameControllerHelper {
|
||||||
int keyCode = event.getKeyCode();
|
int keyCode = event.getKeyCode();
|
||||||
int controllerKey = ControllerKeyMap.get(keyCode);
|
int controllerKey = ControllerKeyMap.get(keyCode);
|
||||||
|
|
||||||
if (controllerKey != 0 && (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
if (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||||
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ))
|
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
||||||
{
|
{
|
||||||
|
int deviceId = event.getDeviceId();
|
||||||
|
String deviceName = event.getDevice().getName();
|
||||||
|
|
||||||
|
if(mGameController.get(deviceId) == null){
|
||||||
|
mGameController.append(deviceId, deviceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controllerKey == 0) {
|
||||||
|
if (mControllerExtendKey.get(deviceId) != null && mControllerExtendKey.get(deviceId).contains(keyCode)) {
|
||||||
|
controllerKey = keyCode;
|
||||||
|
}else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int action = event.getAction();
|
int action = event.getAction();
|
||||||
if (action == KeyEvent.ACTION_DOWN) {
|
if (action == KeyEvent.ACTION_DOWN) {
|
||||||
handled = true;
|
handled = true;
|
||||||
GameControllerAdapter.onButtonEvent(event.getDevice().getName(),event.getDeviceId(), controllerKey,true, 1.0f, false);
|
GameControllerAdapter.onButtonEvent(deviceName, deviceId, controllerKey,true, 1.0f, false);
|
||||||
}else if (action == KeyEvent.ACTION_UP) {
|
}else if (action == KeyEvent.ACTION_UP) {
|
||||||
handled = true;
|
handled = true;
|
||||||
GameControllerAdapter.onButtonEvent(event.getDevice().getName(),event.getDeviceId(), controllerKey,false, 0.0f, false);
|
GameControllerAdapter.onButtonEvent(deviceName, deviceId, controllerKey,false, 0.0f, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void receiveExternalKeyEvent(int deviceId,int externalKeyCode,boolean receive) {
|
||||||
|
if (receive) {
|
||||||
|
if (mControllerExtendKey.get(deviceId) == null) {
|
||||||
|
mControllerExtendKey.put(deviceId, new ArrayList<Integer>());
|
||||||
|
}
|
||||||
|
mControllerExtendKey.get(deviceId).add(externalKeyCode);
|
||||||
|
} else {
|
||||||
|
if (mControllerExtendKey.get(deviceId) != null) {
|
||||||
|
mControllerExtendKey.get(deviceId).remove(Integer.valueOf(externalKeyCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SparseArray<String> mGameController = new SparseArray<String>();
|
||||||
|
|
||||||
|
void onInputDeviceAdded(int deviceId){
|
||||||
|
try {
|
||||||
|
InputDevice device = InputDevice.getDevice(deviceId);
|
||||||
|
int deviceSource = device.getSources();
|
||||||
|
|
||||||
|
if ( ((deviceSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||||
|
|| ((deviceSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
|
||||||
|
{
|
||||||
|
String deviceName = device.getName();
|
||||||
|
mGameController.append(deviceId, deviceName);
|
||||||
|
GameControllerAdapter.onConnected(deviceName, deviceId);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void onInputDeviceChanged(int deviceId){
|
||||||
|
gatherControllers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onInputDeviceRemoved(int deviceId) {
|
||||||
|
if (mGameController.get(deviceId) != null) {
|
||||||
|
GameControllerAdapter.onDisconnected(mGameController.get(deviceId), deviceId);
|
||||||
|
mGameController.delete(deviceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gatherControllers(){
|
||||||
|
int controllerCount = mGameController.size();
|
||||||
|
for (int i = 0; i < controllerCount; i++) {
|
||||||
|
try {
|
||||||
|
int controllerDeveceId = mGameController.keyAt(i);
|
||||||
|
InputDevice device = InputDevice.getDevice(controllerDeveceId);
|
||||||
|
if (device == null) {
|
||||||
|
GameControllerAdapter.onDisconnected(mGameController.get(controllerDeveceId), controllerDeveceId);
|
||||||
|
mGameController.delete(controllerDeveceId);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
int controllerDeveceId = mGameController.keyAt(i);
|
||||||
|
GameControllerAdapter.onDisconnected(mGameController.get(controllerDeveceId), controllerDeveceId);
|
||||||
|
mGameController.delete(controllerDeveceId);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ public class GameControllerNibiru implements OnControllerSeviceListener, OnKeyLi
|
||||||
OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameControllerDelegate {
|
OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameControllerDelegate {
|
||||||
|
|
||||||
private static final String TAG = "NibiruTag";
|
private static final String TAG = "NibiruTag";
|
||||||
private static final String mVendorName = "Nibiru";
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private SparseIntArray mKeyMap;
|
private SparseIntArray mKeyMap;
|
||||||
|
@ -132,7 +131,14 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mControllerEventListener != null) {
|
if (mControllerEventListener != null) {
|
||||||
mControllerEventListener.onButtonEvent(mVendorName, playerOrder, mKeyMap.get(keyCode), true, 1.0f, false);
|
try {
|
||||||
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
|
|
||||||
|
mControllerEventListener.onButtonEvent(controllerDevice.getDeviceName(), controllerDevice.getDeviceId(),
|
||||||
|
mKeyMap.get(keyCode), true, 1.0f, false);
|
||||||
|
} catch (ControllerServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,28 +150,52 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mControllerEventListener != null) {
|
if (mControllerEventListener != null) {
|
||||||
mControllerEventListener.onButtonEvent(mVendorName, playerOrder,
|
try {
|
||||||
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
|
|
||||||
|
mControllerEventListener.onButtonEvent(controllerDevice.getDeviceName(), controllerDevice.getDeviceId(),
|
||||||
mKeyMap.get(keyCode), false, 0.0f, false);
|
mKeyMap.get(keyCode), false, 0.0f, false);
|
||||||
|
} catch (ControllerServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLeftStickChanged(int playerOrder, float x, float y) {
|
public void onLeftStickChanged(int playerOrder, float x, float y) {
|
||||||
if (mControllerEventListener != null) {
|
if (mControllerEventListener != null) {
|
||||||
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
|
try {
|
||||||
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
|
|
||||||
|
String deviceName = controllerDevice.getDeviceName();
|
||||||
|
int deviceId = controllerDevice.getDeviceId();
|
||||||
|
|
||||||
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
|
GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
|
||||||
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
GameControllerDelegate.THUMBSTICK_LEFT_Y, y, true);
|
GameControllerDelegate.THUMBSTICK_LEFT_Y, y, true);
|
||||||
|
} catch (ControllerServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRightStickChanged(int playerOrder, float x, float y) {
|
public void onRightStickChanged(int playerOrder, float x, float y) {
|
||||||
if (mControllerEventListener != null) {
|
if (mControllerEventListener != null) {
|
||||||
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
|
try {
|
||||||
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
|
|
||||||
|
String deviceName = controllerDevice.getDeviceName();
|
||||||
|
int deviceId = controllerDevice.getDeviceId();
|
||||||
|
|
||||||
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
|
GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
|
||||||
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
GameControllerDelegate.THUMBSTICK_RIGHT_Y, y, true);
|
GameControllerDelegate.THUMBSTICK_RIGHT_Y, y, true);
|
||||||
|
} catch (ControllerServiceException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,11 +204,11 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
|
||||||
if (mControllerEventListener != null) {
|
if (mControllerEventListener != null) {
|
||||||
if (state == ControllerDevice.STATE_CONN)
|
if (state == ControllerDevice.STATE_CONN)
|
||||||
{
|
{
|
||||||
mControllerEventListener.onConnected(mVendorName, playerOrder);
|
mControllerEventListener.onConnected(device.getDeviceName(), device.getDeviceId());
|
||||||
}
|
}
|
||||||
else if (state == ControllerDevice.STATE_DISCONN)
|
else if (state == ControllerDevice.STATE_DISCONN)
|
||||||
{
|
{
|
||||||
mControllerEventListener.onDisconnected(mVendorName, playerOrder);
|
mControllerEventListener.onDisconnected(device.getDeviceName(), device.getDeviceId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,6 @@ import android.view.MotionEvent;
|
||||||
|
|
||||||
public class GameControllerOuya implements GameControllerDelegate{
|
public class GameControllerOuya implements GameControllerDelegate{
|
||||||
|
|
||||||
public static final String sVendorName = "Ouya";
|
|
||||||
|
|
||||||
private SparseIntArray mKeyMap;
|
private SparseIntArray mKeyMap;
|
||||||
|
|
||||||
public GameControllerOuya(){
|
public GameControllerOuya(){
|
||||||
|
@ -61,27 +59,28 @@ public class GameControllerOuya implements GameControllerDelegate{
|
||||||
|
|
||||||
if (handled && mControllerEventListener != null)
|
if (handled && mControllerEventListener != null)
|
||||||
{
|
{
|
||||||
OuyaController c = OuyaController.getControllerByDeviceId(event.getDeviceId());
|
int deviceId = event.getDeviceId();
|
||||||
int controllerID = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
|
String deviceName = event.getDevice().getName();
|
||||||
|
OuyaController c = OuyaController.getControllerByDeviceId(deviceId);
|
||||||
|
|
||||||
float newLeftTrigger = c.getAxisValue(OuyaController.AXIS_L2);
|
float newLeftTrigger = c.getAxisValue(OuyaController.AXIS_L2);
|
||||||
if (Float.compare(newLeftTrigger, mOldLeftTrigger) != 0) {
|
if (Float.compare(newLeftTrigger, mOldLeftTrigger) != 0) {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newLeftTrigger, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_LEFT_TRIGGER, newLeftTrigger, true);
|
||||||
mOldLeftTrigger = newLeftTrigger;
|
mOldLeftTrigger = newLeftTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newRightTrigger = c.getAxisValue(OuyaController.AXIS_R2);
|
float newRightTrigger = c.getAxisValue(OuyaController.AXIS_R2);
|
||||||
if (Float.compare(newRightTrigger, mOldRightTrigger) != 0) {
|
if (Float.compare(newRightTrigger, mOldRightTrigger) != 0) {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newRightTrigger, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.BUTTON_RIGHT_TRIGGER, newRightTrigger, true);
|
||||||
mOldRightTrigger = newRightTrigger;
|
mOldRightTrigger = newRightTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newLeftThumbstickX = c.getAxisValue(OuyaController.AXIS_LS_X);
|
float newLeftThumbstickX = c.getAxisValue(OuyaController.AXIS_LS_X);
|
||||||
if (Float.compare(newLeftThumbstickX, mOldLeftThumbstickX) != 0) {
|
if (Float.compare(newLeftThumbstickX, mOldLeftThumbstickX) != 0) {
|
||||||
if (Float.compare(newLeftThumbstickX, 0.0f) == 0) {
|
if (Float.compare(newLeftThumbstickX, 0.0f) == 0) {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_X, 0.0f, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, 0.0f, true);
|
||||||
}else {
|
}else {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_X, newLeftThumbstickX, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, newLeftThumbstickX, true);
|
||||||
}
|
}
|
||||||
mOldLeftThumbstickX = newLeftThumbstickX;
|
mOldLeftThumbstickX = newLeftThumbstickX;
|
||||||
}
|
}
|
||||||
|
@ -89,9 +88,9 @@ public class GameControllerOuya implements GameControllerDelegate{
|
||||||
float newLeftThumbstickY = c.getAxisValue(OuyaController.AXIS_LS_Y);
|
float newLeftThumbstickY = c.getAxisValue(OuyaController.AXIS_LS_Y);
|
||||||
if (Float.compare(newLeftThumbstickY, mOldLeftThumbstickY) != 0) {
|
if (Float.compare(newLeftThumbstickY, mOldLeftThumbstickY) != 0) {
|
||||||
if (Float.compare(newLeftThumbstickY, 0.0f) == 0) {
|
if (Float.compare(newLeftThumbstickY, 0.0f) == 0) {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_Y, 0.0f, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, 0.0f, true);
|
||||||
}else {
|
}else {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_Y, newLeftThumbstickY, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newLeftThumbstickY, true);
|
||||||
}
|
}
|
||||||
mOldLeftThumbstickY = newLeftThumbstickY;
|
mOldLeftThumbstickY = newLeftThumbstickY;
|
||||||
}
|
}
|
||||||
|
@ -99,9 +98,9 @@ public class GameControllerOuya implements GameControllerDelegate{
|
||||||
float newRightThumbstickX = c.getAxisValue(OuyaController.AXIS_RS_X);
|
float newRightThumbstickX = c.getAxisValue(OuyaController.AXIS_RS_X);
|
||||||
if (Float.compare(newRightThumbstickX, mOldRightThumbstickX) != 0) {
|
if (Float.compare(newRightThumbstickX, mOldRightThumbstickX) != 0) {
|
||||||
if (Float.compare(newRightThumbstickX, 0.0f) == 0) {
|
if (Float.compare(newRightThumbstickX, 0.0f) == 0) {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_X, 0.0f, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, 0.0f, true);
|
||||||
}else {
|
}else {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_X, newRightThumbstickX, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newRightThumbstickX, true);
|
||||||
}
|
}
|
||||||
mOldRightThumbstickX = newRightThumbstickX;
|
mOldRightThumbstickX = newRightThumbstickX;
|
||||||
}
|
}
|
||||||
|
@ -109,9 +108,9 @@ public class GameControllerOuya implements GameControllerDelegate{
|
||||||
float newRightThumbstickY = c.getAxisValue(OuyaController.AXIS_RS_Y);
|
float newRightThumbstickY = c.getAxisValue(OuyaController.AXIS_RS_Y);
|
||||||
if (Float.compare(newRightThumbstickY, mOldRightThumbstickY) != 0) {
|
if (Float.compare(newRightThumbstickY, mOldRightThumbstickY) != 0) {
|
||||||
if (Float.compare(newRightThumbstickY, 0.0f) == 0) {
|
if (Float.compare(newRightThumbstickY, 0.0f) == 0) {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_Y, 0.0f, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, 0.0f, true);
|
||||||
}else {
|
}else {
|
||||||
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newRightThumbstickY, true);
|
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newRightThumbstickY, true);
|
||||||
}
|
}
|
||||||
mOldRightThumbstickY = newRightThumbstickY;
|
mOldRightThumbstickY = newRightThumbstickY;
|
||||||
}
|
}
|
||||||
|
@ -122,9 +121,14 @@ public class GameControllerOuya implements GameControllerDelegate{
|
||||||
|
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
|
|
||||||
int action = event.getAction();
|
int action = event.getAction();
|
||||||
int keyCode = event.getKeyCode();
|
int keyCode = event.getKeyCode();
|
||||||
|
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BUTTON_L2 || keyCode == KeyEvent.KEYCODE_BUTTON_R2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (action == KeyEvent.ACTION_DOWN) {
|
if (action == KeyEvent.ACTION_DOWN) {
|
||||||
handled = OuyaController.onKeyDown(keyCode, event);
|
handled = OuyaController.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
@ -139,11 +143,10 @@ public class GameControllerOuya implements GameControllerDelegate{
|
||||||
isAnalog = true;
|
isAnalog = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int controllerID = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
|
|
||||||
if (action == KeyEvent.ACTION_DOWN) {
|
if (action == KeyEvent.ACTION_DOWN) {
|
||||||
mControllerEventListener.onButtonEvent(sVendorName, controllerID, mKeyMap.get(keyCode), true, 1.0f, isAnalog);
|
mControllerEventListener.onButtonEvent(event.getDevice().getName(), event.getDeviceId(), mKeyMap.get(keyCode), true, 1.0f, isAnalog);
|
||||||
}else {
|
}else {
|
||||||
mControllerEventListener.onButtonEvent(sVendorName, controllerID, mKeyMap.get(keyCode), false, 0.0f, isAnalog);
|
mControllerEventListener.onButtonEvent(event.getDevice().getName(), event.getDeviceId(), mKeyMap.get(keyCode), false, 0.0f, isAnalog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -711,7 +711,7 @@ std::string Texture2D::getDescription() const
|
||||||
// implementation Texture2D (Image)
|
// implementation Texture2D (Image)
|
||||||
bool Texture2D::initWithImage(Image *image)
|
bool Texture2D::initWithImage(Image *image)
|
||||||
{
|
{
|
||||||
return initWithImage(image, image->getRenderFormat());
|
return initWithImage(image, PixelFormat::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
bool Texture2D::initWithImage(Image *image, PixelFormat format)
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2rc0.zip
|
* 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
|
* 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.2beta0/index.html
|
* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2rc0/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)
|
* 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
|
# Requirements
|
||||||
|
@ -116,7 +116,7 @@ Please refer to this document: [ReadMe](../README.md)
|
||||||
|
|
||||||
# Highlights of v3.2rc0
|
# Highlights of v3.2rc0
|
||||||
|
|
||||||
* `fbx-conv` support generating binary format, and `Sprite3D` support it, and about
|
* `fbx-conv` support generating binary format, and `Sprite3D` support it
|
||||||
* about 20% performance improved in `Sprite3D`
|
* about 20% performance improved in `Sprite3D`
|
||||||
* game controller support
|
* game controller support
|
||||||
* fast tilemap support, it is faster for static tilemap
|
* fast tilemap support, it is faster for static tilemap
|
||||||
|
|
|
@ -183,7 +183,7 @@ g_guisTests[] =
|
||||||
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
||||||
sceneManager->setCurrentUISceneId(kUIPageViewTest);
|
sceneManager->setCurrentUISceneId(kUIPageViewTest);
|
||||||
sceneManager->setMinUISceneId(kUIPageViewTest);
|
sceneManager->setMinUISceneId(kUIPageViewTest);
|
||||||
sceneManager->setMaxUISceneId(kUIPageViewTest);
|
sceneManager->setMaxUISceneId(kUIPageViewButtonTest);
|
||||||
Scene* scene = sceneManager->currentUIScene();
|
Scene* scene = sceneManager->currentUIScene();
|
||||||
Director::getInstance()->replaceScene(scene);
|
Director::getInstance()->replaceScene(scene);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,29 +16,40 @@ UIButtonTest_Editor::~UIButtonTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIButtonTest_Editor::init()
|
void UIButtonTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// auto _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
|
|
||||||
|
|
||||||
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.csb"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIButtonTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = Director::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
(screenSize.height - rootSize.height) / 2));
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
ui::Text* back_label = static_cast<ui::Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<ui::Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
Button* button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_123"));
|
Button* button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_123"));
|
||||||
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
||||||
|
@ -47,15 +58,28 @@ bool UIButtonTest_Editor::init()
|
||||||
title_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
title_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
||||||
|
|
||||||
Button* scale9_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_129"));
|
Button* scale9_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_129"));
|
||||||
scale9_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
scale9_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent,this));
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
}
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
|
bool UIButtonTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
|
|
||||||
|
_displayValueLabel = ui::Text::create();
|
||||||
|
_displayValueLabel->setFontName("Marker Felt");
|
||||||
_displayValueLabel->setFontSize(30);
|
_displayValueLabel->setFontSize(30);
|
||||||
_displayValueLabel->setString("No event");
|
_displayValueLabel->setString("No event");
|
||||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||||
_touchGroup->addChild(_displayValueLabel);
|
|
||||||
|
_touchGroup->addChild(_displayValueLabel,20);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ public:
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
void touchEvent(Ref* pSender, Widget::TouchEventType type);
|
void touchEvent(Ref* pSender, Widget::TouchEventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIButtonTest_Editor);
|
UI_SCENE_EDITOR_CREATE_FUNC(UIButtonTest_Editor);
|
||||||
|
|
|
@ -16,13 +16,29 @@ UICheckBoxTest_Editor::~UICheckBoxTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UICheckBoxTest_Editor::init()
|
void UICheckBoxTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.csb"));
|
if (item->getSelectedIndex() == 0){
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_2.json"));
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.json"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.csb"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UICheckBoxTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -38,13 +54,24 @@ bool UICheckBoxTest_Editor::init()
|
||||||
CheckBox* checkbox = static_cast<CheckBox*>(Helper::seekWidgetByName(root, "CheckBox_540"));
|
CheckBox* checkbox = static_cast<CheckBox*>(Helper::seekWidgetByName(root, "CheckBox_540"));
|
||||||
checkbox->addEventListener(CC_CALLBACK_2(UICheckBoxTest_Editor::selectedStateEvent, this));
|
checkbox->addEventListener(CC_CALLBACK_2(UICheckBoxTest_Editor::selectedStateEvent, this));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UICheckBoxTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create();
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||||
_displayValueLabel->setFontSize(30);
|
_displayValueLabel->setFontSize(30);
|
||||||
_displayValueLabel->setString("No event");
|
_displayValueLabel->setString("No event");
|
||||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||||
_touchGroup->addChild(_displayValueLabel);
|
_touchGroup->addChild(_displayValueLabel,20);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public:
|
||||||
~UICheckBoxTest_Editor();
|
~UICheckBoxTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void selectedStateEvent(Ref* pSender, CheckBox::EventType type);
|
void selectedStateEvent(Ref* pSender, CheckBox::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UICheckBoxTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UICheckBoxTest_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
|
|
@ -4,15 +4,29 @@
|
||||||
|
|
||||||
|
|
||||||
// UIImageViewTest_Editor
|
// UIImageViewTest_Editor
|
||||||
|
void UIImageViewTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
bool UIImageViewTest_Editor::init()
|
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.json"));
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.csb"));
|
|
||||||
|
|
||||||
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.json"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.csb"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIImageViewTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -25,6 +39,19 @@ bool UIImageViewTest_Editor::init()
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIImageViewTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.json"));
|
||||||
|
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ class UIImageViewTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIImageViewTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIImageViewTest_Editor)
|
||||||
|
|
|
@ -15,13 +15,29 @@ UILayoutTest_Editor::~UILayoutTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Editor::init()
|
void UILayoutTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -52,6 +68,18 @@ bool UILayoutTest_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,13 +99,29 @@ UILayoutTest_Color_Editor::~UILayoutTest_Color_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Color_Editor::init()
|
void UILayoutTest_Color_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Color_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -107,7 +151,16 @@ bool UILayoutTest_Color_Editor::init()
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Color_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +180,29 @@ UILayoutTest_Gradient_Editor::~UILayoutTest_Gradient_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Gradient_Editor::init()
|
void UILayoutTest_Gradient_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Gradient_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -164,6 +233,16 @@ bool UILayoutTest_Gradient_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Gradient_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,13 +262,29 @@ UILayoutTest_BackGroundImage_Editor::~UILayoutTest_BackGroundImage_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_BackGroundImage_Editor::init()
|
void UILayoutTest_BackGroundImage_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_BackGroundImage_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -220,6 +315,17 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_BackGroundImage_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,13 +345,29 @@ UILayoutTest_BackGroundImage_Scale9_Editor::~UILayoutTest_BackGroundImage_Scale9
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
void UILayoutTest_BackGroundImage_Scale9_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_BackGroundImage_Scale9_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -276,6 +398,17 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,13 +428,29 @@ UILayoutTest_Layout_Linear_Vertical_Editor::~UILayoutTest_Layout_Linear_Vertical
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
void UILayoutTest_Layout_Linear_Vertical_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Linear_Vertical_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -332,6 +481,17 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,13 +511,29 @@ UILayoutTest_Layout_Linear_Horizontal_Editor::~UILayoutTest_Layout_Linear_Horizo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
void UILayoutTest_Layout_Linear_Horizontal_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Linear_Horizontal_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -388,6 +564,16 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -408,13 +594,29 @@ UILayoutTest_Layout_Relative_Align_Parent_Editor::~UILayoutTest_Layout_Relative_
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
void UILayoutTest_Layout_Relative_Align_Parent_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Relative_Align_Parent_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -445,6 +647,16 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,13 +676,29 @@ UILayoutTest_Layout_Relative_Location_Editor::~UILayoutTest_Layout_Relative_Loca
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
void UILayoutTest_Layout_Relative_Location_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Relative_Location_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -501,6 +729,15 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ public:
|
||||||
UILayoutTest_Editor();
|
UILayoutTest_Editor();
|
||||||
~UILayoutTest_Editor();
|
~UILayoutTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Editor)
|
||||||
};
|
};
|
||||||
|
@ -45,7 +46,8 @@ public:
|
||||||
UILayoutTest_Color_Editor();
|
UILayoutTest_Color_Editor();
|
||||||
~UILayoutTest_Color_Editor();
|
~UILayoutTest_Color_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Color_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Color_Editor)
|
||||||
};
|
};
|
||||||
|
@ -57,7 +59,8 @@ public:
|
||||||
UILayoutTest_Gradient_Editor();
|
UILayoutTest_Gradient_Editor();
|
||||||
~UILayoutTest_Gradient_Editor();
|
~UILayoutTest_Gradient_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Gradient_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Gradient_Editor)
|
||||||
};
|
};
|
||||||
|
@ -69,7 +72,8 @@ public:
|
||||||
UILayoutTest_BackGroundImage_Editor();
|
UILayoutTest_BackGroundImage_Editor();
|
||||||
~UILayoutTest_BackGroundImage_Editor();
|
~UILayoutTest_BackGroundImage_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_BackGroundImage_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_BackGroundImage_Editor)
|
||||||
};
|
};
|
||||||
|
@ -81,7 +85,8 @@ public:
|
||||||
UILayoutTest_BackGroundImage_Scale9_Editor();
|
UILayoutTest_BackGroundImage_Scale9_Editor();
|
||||||
~UILayoutTest_BackGroundImage_Scale9_Editor();
|
~UILayoutTest_BackGroundImage_Scale9_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_BackGroundImage_Scale9_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_BackGroundImage_Scale9_Editor)
|
||||||
};
|
};
|
||||||
|
@ -92,6 +97,8 @@ class UILayoutTest_Layout_Linear_Vertical_Editor : public UIScene_Editor
|
||||||
public:
|
public:
|
||||||
UILayoutTest_Layout_Linear_Vertical_Editor();
|
UILayoutTest_Layout_Linear_Vertical_Editor();
|
||||||
~UILayoutTest_Layout_Linear_Vertical_Editor();
|
~UILayoutTest_Layout_Linear_Vertical_Editor();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -105,7 +112,8 @@ public:
|
||||||
UILayoutTest_Layout_Linear_Horizontal_Editor();
|
UILayoutTest_Layout_Linear_Horizontal_Editor();
|
||||||
~UILayoutTest_Layout_Linear_Horizontal_Editor();
|
~UILayoutTest_Layout_Linear_Horizontal_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Linear_Horizontal_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Linear_Horizontal_Editor)
|
||||||
};
|
};
|
||||||
|
@ -117,7 +125,8 @@ public:
|
||||||
UILayoutTest_Layout_Relative_Align_Parent_Editor();
|
UILayoutTest_Layout_Relative_Align_Parent_Editor();
|
||||||
~UILayoutTest_Layout_Relative_Align_Parent_Editor();
|
~UILayoutTest_Layout_Relative_Align_Parent_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Relative_Align_Parent_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Relative_Align_Parent_Editor)
|
||||||
};
|
};
|
||||||
|
@ -129,7 +138,8 @@ public:
|
||||||
UILayoutTest_Layout_Relative_Location_Editor();
|
UILayoutTest_Layout_Relative_Location_Editor();
|
||||||
~UILayoutTest_Layout_Relative_Location_Editor();
|
~UILayoutTest_Layout_Relative_Location_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Relative_Location_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Relative_Location_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,13 +15,29 @@ UIListViewTest_Vertical_Editor::~UIListViewTest_Vertical_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIListViewTest_Vertical_Editor::init()
|
void UIListViewTest_Vertical_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIListViewTest_Vertical_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -34,8 +50,8 @@ bool UIListViewTest_Vertical_Editor::init()
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
// ListView* listView = static_cast<ListView*>(UIHelper::seekWidgetByName(root, "ListView_1214"));
|
// ListView* listView = static_cast<ListView*>(UIHelper::seekWidgetByName(root, "ListView_1214"));
|
||||||
// CCLOG("listView isBounceEnabled = %d", listView->isBounceEnabled());
|
// CCLOG("listView isBounceEnabled = %d", listView->isBounceEnabled());
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
Button* left_button = Button::create();
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
@ -57,6 +73,16 @@ bool UIListViewTest_Vertical_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIListViewTest_Vertical_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,18 +98,29 @@ UIListViewTest_Horizontal_Editor::UIListViewTest_Horizontal_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UIListViewTest_Horizontal_Editor::~UIListViewTest_Horizontal_Editor()
|
void UIListViewTest_Horizontal_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
|
|
||||||
}
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
bool UIListViewTest_Horizontal_Editor::init()
|
|
||||||
{
|
|
||||||
if (UIScene_Editor::init())
|
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.json"));
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIListViewTest_Horizontal_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -113,6 +150,22 @@ bool UIListViewTest_Horizontal_Editor::init()
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UIListViewTest_Horizontal_Editor::~UIListViewTest_Horizontal_Editor()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIListViewTest_Horizontal_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ public:
|
||||||
~UIListViewTest_Vertical_Editor();
|
~UIListViewTest_Vertical_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void selectedItemEvent(Ref* pSender, ListView::EventType type);
|
void selectedItemEvent(Ref* pSender, ListView::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIListViewTest_Vertical_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIListViewTest_Vertical_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
@ -50,7 +51,8 @@ public:
|
||||||
~UIListViewTest_Horizontal_Editor();
|
~UIListViewTest_Horizontal_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void selectedItemEvent(Ref* pSender, ListView::EventType type);
|
void selectedItemEvent(Ref* pSender, ListView::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIListViewTest_Horizontal_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIListViewTest_Horizontal_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
|
|
@ -16,15 +16,29 @@ UILoadingBarTest_Editor::~UILoadingBarTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILoadingBarTest_Editor::init()
|
void UILoadingBarTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
scheduleUpdate();
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILoadingBarTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -33,7 +47,7 @@ bool UILoadingBarTest_Editor::init()
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
|
// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
@ -44,6 +58,18 @@ bool UILoadingBarTest_Editor::init()
|
||||||
LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_857"));
|
LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_857"));
|
||||||
loadingBar_right_to_left->setPercent(0);
|
loadingBar_right_to_left->setPercent(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UILoadingBarTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
scheduleUpdate();
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@ public:
|
||||||
bool init();
|
bool init();
|
||||||
void update(float delta);
|
void update(float delta);
|
||||||
void toCocosGUITestScene(Ref* sender, Widget::TouchEventType event);
|
void toCocosGUITestScene(Ref* sender, Widget::TouchEventType event);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UILoadingBarTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UILoadingBarTest_Editor)
|
||||||
int _count;
|
int _count;
|
||||||
|
|
|
@ -97,3 +97,114 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UIPageViewButtonTest
|
||||||
|
UIPageViewButtonTest::UIPageViewButtonTest()
|
||||||
|
: _displayValueLabel(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UIPageViewButtonTest::~UIPageViewButtonTest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIPageViewButtonTest::init()
|
||||||
|
{
|
||||||
|
if (UIScene::init())
|
||||||
|
{
|
||||||
|
Size widgetSize = _widget->getContentSize();
|
||||||
|
|
||||||
|
// Add a label in which the dragpanel events will be displayed
|
||||||
|
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
|
||||||
|
_displayValueLabel->setAnchorPoint(Vec2(0.5f, -1.0f));
|
||||||
|
_displayValueLabel->setPosition(Vec2(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f +
|
||||||
|
_displayValueLabel->getContentSize().height * 1.5));
|
||||||
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
|
// Add the black background
|
||||||
|
Text* alert = Text::create("PageView with Buttons", "fonts/Marker Felt.ttf", 30);
|
||||||
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
|
alert->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getContentSize().height * 3.075f));
|
||||||
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||||
|
|
||||||
|
Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
|
||||||
|
|
||||||
|
// Create the page view
|
||||||
|
PageView* pageView = PageView::create();
|
||||||
|
pageView->setContentSize(Size(240.0f, 130.0f));
|
||||||
|
Size backgroundSize = background->getContentSize();
|
||||||
|
pageView->setPosition(Vec2((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||||
|
(backgroundSize.width - pageView->getContentSize().width) / 2.0f,
|
||||||
|
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||||
|
(backgroundSize.height - pageView->getContentSize().height) / 2.0f));
|
||||||
|
|
||||||
|
pageView->removeAllPages();
|
||||||
|
|
||||||
|
int pageCount = 4;
|
||||||
|
for (int i = 0; i < pageCount; ++i)
|
||||||
|
{
|
||||||
|
HBox* outerBox = HBox::create();
|
||||||
|
outerBox->setContentSize(Size(240.0f, 130.0f));
|
||||||
|
|
||||||
|
for (int k = 0; k < 2; ++k) {
|
||||||
|
VBox* innerBox = VBox::create();
|
||||||
|
|
||||||
|
for (int j = 0; j < 3; j++) {
|
||||||
|
Button *btn = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
|
"cocosui/animationbuttonpressed.png");
|
||||||
|
btn->setName(StringUtils::format("button %d", j));
|
||||||
|
btn->addTouchEventListener( CC_CALLBACK_2(UIPageViewButtonTest::onButtonClicked, this));
|
||||||
|
|
||||||
|
innerBox->addChild(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
LinearLayoutParameter *parameter = LinearLayoutParameter::create();
|
||||||
|
parameter->setMargin(Margin(0,0,100,0));
|
||||||
|
innerBox->setLayoutParameter(parameter);
|
||||||
|
|
||||||
|
outerBox->addChild(innerBox);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pageView->insertPage(outerBox,i);
|
||||||
|
}
|
||||||
|
|
||||||
|
pageView->removePageAtIndex(0);
|
||||||
|
|
||||||
|
pageView->addEventListener(CC_CALLBACK_2(UIPageViewButtonTest::pageViewEvent, this));
|
||||||
|
|
||||||
|
_uiLayer->addChild(pageView);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIPageViewButtonTest::onButtonClicked(Ref* pSender, Widget::TouchEventType type)
|
||||||
|
{
|
||||||
|
Button *btn = (Button*)pSender;
|
||||||
|
CCLOG("button %s clicked", btn->getName().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UIPageViewButtonTest::pageViewEvent(Ref *pSender, PageView::EventType type)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case PageView::EventType::TURNING:
|
||||||
|
{
|
||||||
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
|
_displayValueLabel->setString(CCString::createWithFormat("page = %ld", pageView->getCurPageIndex() + 1)->getCString());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -41,4 +41,18 @@ protected:
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UIPageViewButtonTest : public UIScene
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UIPageViewButtonTest();
|
||||||
|
~UIPageViewButtonTest();
|
||||||
|
bool init();
|
||||||
|
|
||||||
|
void pageViewEvent(Ref* pSender, PageView::EventType type);
|
||||||
|
void onButtonClicked(Ref* pSender, Widget::TouchEventType type);
|
||||||
|
protected:
|
||||||
|
UI_SCENE_CREATE_FUNC(UIPageViewButtonTest)
|
||||||
|
Text* _displayValueLabel;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* defined(__TestCpp__UIPageViewTest__) */
|
#endif /* defined(__TestCpp__UIPageViewTest__) */
|
||||||
|
|
|
@ -16,13 +16,30 @@ UIPageViewTest_Editor::~UIPageViewTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIPageViewTest_Editor::init()
|
void UIPageViewTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIPageViewTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -53,6 +70,16 @@ bool UIPageViewTest_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIPageViewTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ public:
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
void pageViewEvent(Ref* pSender, PageView::EventType type);
|
void pageViewEvent(Ref* pSender, PageView::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIPageViewTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIPageViewTest_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
|
|
@ -100,7 +100,8 @@ static const char* s_testArray[] =
|
||||||
"UIScrollViewTest_Both",
|
"UIScrollViewTest_Both",
|
||||||
"UIScrollViewTest_ScrollToPercentBothDirection",
|
"UIScrollViewTest_ScrollToPercentBothDirection",
|
||||||
"UIScrollViewTest_ScrollToPercentBothDirection_Bounce",
|
"UIScrollViewTest_ScrollToPercentBothDirection_Bounce",
|
||||||
"UIPageViewTest,",
|
"UIPageViewTest",
|
||||||
|
"UIPageViewButtonTest",
|
||||||
"UIListViewTest_Vertical",
|
"UIListViewTest_Vertical",
|
||||||
"UIListViewTest_Horizontal",
|
"UIListViewTest_Horizontal",
|
||||||
/*
|
/*
|
||||||
|
@ -344,7 +345,8 @@ Scene *UISceneManager::currentUIScene()
|
||||||
|
|
||||||
case kUIPageViewTest:
|
case kUIPageViewTest:
|
||||||
return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||||
|
case kUIPageViewButtonTest:
|
||||||
|
return UIPageViewButtonTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||||
case kUIListViewTest_Vertical:
|
case kUIListViewTest_Vertical:
|
||||||
return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
|
return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ enum
|
||||||
kUIScrollViewTest_ScrollToPercentBothDirection,
|
kUIScrollViewTest_ScrollToPercentBothDirection,
|
||||||
kUIScrollViewTest_ScrollToPercentBothDirection_Bounce,
|
kUIScrollViewTest_ScrollToPercentBothDirection_Bounce,
|
||||||
kUIPageViewTest,
|
kUIPageViewTest,
|
||||||
|
kUIPageViewButtonTest,
|
||||||
kUIListViewTest_Vertical,
|
kUIListViewTest_Vertical,
|
||||||
kUIListViewTest_Horizontal,
|
kUIListViewTest_Horizontal,
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -26,12 +26,37 @@ bool UIScene_Editor::init()
|
||||||
_touchGroup = Layer::create();
|
_touchGroup = Layer::create();
|
||||||
addChild(_touchGroup);
|
addChild(_touchGroup);
|
||||||
|
|
||||||
|
//add switch
|
||||||
|
MenuItem* pLoadJsonItem = MenuItemFont::create("Switch to Binary Load");
|
||||||
|
MenuItem* pLoadBinaryItem = MenuItemFont::create("Switch to Json Load");
|
||||||
|
|
||||||
|
pLoadJsonItem->setTag(1);
|
||||||
|
pLoadBinaryItem->setTag(2);
|
||||||
|
|
||||||
|
Vector<MenuItem*> array;;
|
||||||
|
array.pushBack(pLoadJsonItem);
|
||||||
|
array.pushBack(pLoadBinaryItem);
|
||||||
|
|
||||||
|
MenuItemToggle *pToggleItem = MenuItemToggle::createWithCallback(CC_CALLBACK_1(UIScene_Editor::switchLoadMethod,this), array);
|
||||||
|
|
||||||
|
pToggleItem->setPosition(Vec2(VisibleRect::right().x - 150, VisibleRect::top().y - 50));;
|
||||||
|
|
||||||
|
Menu* pMenu =Menu::create(pToggleItem, NULL);
|
||||||
|
pMenu->setPosition( Vec2::ZERO );
|
||||||
|
|
||||||
|
addChild(pMenu, 1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIScene_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
|
{
|
||||||
|
//subclass should override this method
|
||||||
|
}
|
||||||
|
|
||||||
void UIScene_Editor::previousCallback(Ref* sender, Widget::TouchEventType event)
|
void UIScene_Editor::previousCallback(Ref* sender, Widget::TouchEventType event)
|
||||||
{
|
{
|
||||||
switch (event)
|
switch (event)
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle)
|
CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle)
|
||||||
|
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIScene_Editor);
|
UI_SCENE_EDITOR_CREATE_FUNC(UIScene_Editor);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Layer* _touchGroup;
|
Layer* _touchGroup;
|
||||||
|
|
|
@ -15,13 +15,30 @@ UIScrollViewTest_Vertical_Editor::~UIScrollViewTest_Vertical_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIScrollViewTest_Vertical_Editor::init()
|
void UIScrollViewTest_Vertical_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Vertical_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -52,6 +69,16 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIScrollViewTest_Vertical_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,13 +98,30 @@ UIScrollViewTest_Horizontal_Editor::~UIScrollViewTest_Horizontal_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIScrollViewTest_Horizontal_Editor::init()
|
void UIScrollViewTest_Horizontal_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Horizontal_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -108,6 +152,16 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIScrollViewTest_Horizontal_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,13 +181,30 @@ UIScrollViewTest_Both_Editor::~UIScrollViewTest_Both_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIScrollViewTest_Both_Editor::init()
|
void UIScrollViewTest_Both_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Both_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -163,7 +234,15 @@ bool UIScrollViewTest_Both_Editor::init()
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
_layout->addChild(right_button);
|
_layout->addChild(right_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UIScrollViewTest_Both_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +262,7 @@ UIScrollViewTest_ScrollToPercentBothDirection_Editor::~UIScrollViewTest_ScrollTo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init()
|
bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
|
|
|
@ -33,7 +33,8 @@ public:
|
||||||
UIScrollViewTest_Vertical_Editor();
|
UIScrollViewTest_Vertical_Editor();
|
||||||
~UIScrollViewTest_Vertical_Editor();
|
~UIScrollViewTest_Vertical_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Vertical_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Vertical_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
@ -46,7 +47,8 @@ public:
|
||||||
UIScrollViewTest_Horizontal_Editor();
|
UIScrollViewTest_Horizontal_Editor();
|
||||||
~UIScrollViewTest_Horizontal_Editor();
|
~UIScrollViewTest_Horizontal_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Horizontal_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Horizontal_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
@ -59,7 +61,8 @@ public:
|
||||||
UIScrollViewTest_Both_Editor();
|
UIScrollViewTest_Both_Editor();
|
||||||
~UIScrollViewTest_Both_Editor();
|
~UIScrollViewTest_Both_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Both_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Both_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
|
|
@ -16,13 +16,30 @@ UISliderTest_Editor::~UISliderTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UISliderTest_Editor::init()
|
void UISliderTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UISliderTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -41,7 +58,16 @@ bool UISliderTest_Editor::init()
|
||||||
|
|
||||||
Slider* scale9_slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_740"));
|
Slider* scale9_slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_740"));
|
||||||
scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UISliderTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create();
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||||
|
@ -49,7 +75,7 @@ bool UISliderTest_Editor::init()
|
||||||
_displayValueLabel->setString("No event");
|
_displayValueLabel->setString("No event");
|
||||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||||
_touchGroup->addChild(_displayValueLabel);
|
_touchGroup->addChild(_displayValueLabel, 20);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ public:
|
||||||
~UISliderTest_Editor();
|
~UISliderTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void sliderEvent(Ref* pSender, Slider::EventType type);
|
void sliderEvent(Ref* pSender, Slider::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UISliderTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UISliderTest_Editor)
|
||||||
|
|
|
@ -3,14 +3,30 @@
|
||||||
#include "UITextAtlasTest_Editor.h"
|
#include "UITextAtlasTest_Editor.h"
|
||||||
|
|
||||||
// UITextAtlasTest_Editor
|
// UITextAtlasTest_Editor
|
||||||
|
void UITextAtlasTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
bool UITextAtlasTest_Editor::init()
|
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextAtlasTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -22,7 +38,16 @@ bool UITextAtlasTest_Editor::init()
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UITextAtlasTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class UITextAtlasTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextAtlasTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextAtlasTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,14 +4,30 @@
|
||||||
|
|
||||||
|
|
||||||
// UITextBMFontTest_Editor
|
// UITextBMFontTest_Editor
|
||||||
|
void UITextBMFontTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
bool UITextBMFontTest_Editor::init()
|
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextBMFontTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -23,7 +39,16 @@ bool UITextBMFontTest_Editor::init()
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UITextBMFontTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class UITextBMFontTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextBMFontTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextBMFontTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,13 +16,30 @@ UITextFieldTest_Editor::~UITextFieldTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UITextFieldTest_Editor::init()
|
void UITextFieldTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextFieldTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -43,6 +60,16 @@ bool UITextFieldTest_Editor::init()
|
||||||
|
|
||||||
TextField* textField_password = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1107"));
|
TextField* textField_password = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1107"));
|
||||||
textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UITextFieldTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create();
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||||
|
@ -50,7 +77,7 @@ bool UITextFieldTest_Editor::init()
|
||||||
_displayValueLabel->setString("No event");
|
_displayValueLabel->setString("No event");
|
||||||
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
|
||||||
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
|
||||||
_touchGroup->addChild(_displayValueLabel);
|
_touchGroup->addChild(_displayValueLabel, 20);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ public:
|
||||||
~UITextFieldTest_Editor();
|
~UITextFieldTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
void textFieldEvent(Ref* pSender, TextField::EventType type);
|
void textFieldEvent(Ref* pSender, TextField::EventType type);
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextFieldTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextFieldTest_Editor)
|
||||||
Text* _displayValueLabel;
|
Text* _displayValueLabel;
|
||||||
|
|
|
@ -7,13 +7,30 @@
|
||||||
// UITextTest_Editor
|
// UITextTest_Editor
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
bool UITextTest_Editor::init()
|
void UITextTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -26,6 +43,15 @@ bool UITextTest_Editor::init()
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UITextTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ class UITextTest_Editor : public UIScene_Editor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UITextTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UITextTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,13 +15,30 @@ UIWidgetAddNodeTest_Editor::~UIWidgetAddNodeTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIWidgetAddNodeTest_Editor::init()
|
void UIWidgetAddNodeTest_Editor::switchLoadMethod(cocos2d::Ref *pSender)
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
MenuItemToggle *item = (MenuItemToggle*)pSender;
|
||||||
{
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
if (item->getSelectedIndex() == 0){
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
||||||
|
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb"));
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIWidgetAddNodeTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
Size rootSize = _layout->getContentSize();
|
Size rootSize = _layout->getContentSize();
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
@ -44,6 +61,17 @@ bool UIWidgetAddNodeTest_Editor::init()
|
||||||
Sprite* sprite = Sprite::create("cocosui/ccicon.png");
|
Sprite* sprite = Sprite::create("cocosui/ccicon.png");
|
||||||
widget->addChild(sprite);
|
widget->addChild(sprite);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool UIWidgetAddNodeTest_Editor::init()
|
||||||
|
{
|
||||||
|
if (UIScene_Editor::init())
|
||||||
|
{
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ public:
|
||||||
UIWidgetAddNodeTest_Editor();
|
UIWidgetAddNodeTest_Editor();
|
||||||
~UIWidgetAddNodeTest_Editor();
|
~UIWidgetAddNodeTest_Editor();
|
||||||
bool init();
|
bool init();
|
||||||
|
virtual void switchLoadMethod(Ref* pSender);
|
||||||
|
void configureGUIScene();
|
||||||
protected:
|
protected:
|
||||||
UI_SCENE_EDITOR_CREATE_FUNC(UIWidgetAddNodeTest_Editor)
|
UI_SCENE_EDITOR_CREATE_FUNC(UIWidgetAddNodeTest_Editor)
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,20 +33,27 @@ void GameControllerTest::onConnectController(Controller* controller, Event* even
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||||
|
//receive back key
|
||||||
|
controller->receiveExternalKeyEvent(4,true);
|
||||||
|
//receive menu key
|
||||||
|
controller->receiveExternalKeyEvent(82,true);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char deviceInfo[50];
|
||||||
|
sprintf(deviceInfo,"%s id:%d",controller->getDeviceName().c_str(), controller->getDeviceId());
|
||||||
|
|
||||||
if (_firstHolder.controller == nullptr && _secondHolder.controller == nullptr)
|
if (_firstHolder.controller == nullptr && _secondHolder.controller == nullptr)
|
||||||
{
|
{
|
||||||
char deviceId[20];
|
|
||||||
sprintf(deviceId,"device id:%d",controller->getDeviceId());
|
|
||||||
|
|
||||||
if (_firstHolder._holderNode)
|
if (_firstHolder._holderNode)
|
||||||
{
|
{
|
||||||
_firstHolder.controller = controller;
|
_firstHolder.controller = controller;
|
||||||
_firstHolder._deviceIdLabel->setString(deviceId);
|
_firstHolder._deviceLabel->setString(deviceInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_secondHolder.controller = controller;
|
_secondHolder.controller = controller;
|
||||||
_secondHolder._deviceIdLabel->setString(deviceId);
|
_secondHolder._deviceLabel->setString(deviceInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(_secondHolder.controller == nullptr)
|
else if(_secondHolder.controller == nullptr)
|
||||||
|
@ -66,9 +73,7 @@ void GameControllerTest::onConnectController(Controller* controller, Event* even
|
||||||
this->addChild(_secondHolder._holderNode);
|
this->addChild(_secondHolder._holderNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
char deviceId[20];
|
_secondHolder._deviceLabel->setString(deviceInfo);
|
||||||
sprintf(deviceId,"device id:%d",controller->getDeviceId());
|
|
||||||
_secondHolder._deviceIdLabel->setString(deviceId);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -86,9 +91,8 @@ void GameControllerTest::onConnectController(Controller* controller, Event* even
|
||||||
_firstHolder._holderNode->setPosition(Vec2(_visibleThreeQuarterX, _visibleCentreY));
|
_firstHolder._holderNode->setPosition(Vec2(_visibleThreeQuarterX, _visibleCentreY));
|
||||||
this->addChild(_firstHolder._holderNode);
|
this->addChild(_firstHolder._holderNode);
|
||||||
}
|
}
|
||||||
char deviceId[20];
|
|
||||||
sprintf(deviceId,"device id:%d",controller->getDeviceId());
|
_firstHolder._deviceLabel->setString(deviceInfo);
|
||||||
_firstHolder._deviceIdLabel->setString(deviceId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +148,7 @@ void GameControllerTest::resetControllerHolderState(ControllerHolder& holder)
|
||||||
|
|
||||||
holder._leftJoystick->setPosition(Vec2(238,460));
|
holder._leftJoystick->setPosition(Vec2(238,460));
|
||||||
holder._rightJoystick->setPosition(Vec2(606,293));
|
holder._rightJoystick->setPosition(Vec2(606,293));
|
||||||
holder._deviceIdLabel->setString("Disconnected");
|
holder._deviceLabel->setString("Disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameControllerTest::showButtonState(cocos2d::Controller *controller, int keyCode, bool isPressed)
|
void GameControllerTest::showButtonState(cocos2d::Controller *controller, int keyCode, bool isPressed)
|
||||||
|
@ -193,9 +197,14 @@ void GameControllerTest::showButtonState(cocos2d::Controller *controller, int ke
|
||||||
holder->_buttonR1->setColor(Color3B(19,231,238));
|
holder->_buttonR1->setColor(Color3B(19,231,238));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
char ketStatus[30];
|
||||||
|
sprintf(ketStatus,"Key Down:%d",keyCode);
|
||||||
|
holder->_externalKeyLabel->setString(ketStatus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
|
@ -231,9 +240,14 @@ void GameControllerTest::showButtonState(cocos2d::Controller *controller, int ke
|
||||||
holder->_buttonR1->setColor(Color3B::WHITE);
|
holder->_buttonR1->setColor(Color3B::WHITE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
char ketStatus[30];
|
||||||
|
sprintf(ketStatus,"Key Up:%d",keyCode);
|
||||||
|
holder->_externalKeyLabel->setString(ketStatus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameControllerTest::onKeyDown(cocos2d::Controller *controller, int keyCode, cocos2d::Event *event)
|
void GameControllerTest::onKeyDown(cocos2d::Controller *controller, int keyCode, cocos2d::Event *event)
|
||||||
|
@ -248,7 +262,6 @@ void GameControllerTest::onKeyUp(cocos2d::Controller *controller, int keyCode, c
|
||||||
|
|
||||||
void GameControllerTest::onAxisEvent(cocos2d::Controller* controller, int keyCode, cocos2d::Event* event)
|
void GameControllerTest::onAxisEvent(cocos2d::Controller* controller, int keyCode, cocos2d::Event* event)
|
||||||
{
|
{
|
||||||
//onConnectController(controller,nullptr);
|
|
||||||
ControllerHolder* holder = nullptr;
|
ControllerHolder* holder = nullptr;
|
||||||
if (controller == _firstHolder.controller)
|
if (controller == _firstHolder.controller)
|
||||||
holder = &_firstHolder;
|
holder = &_firstHolder;
|
||||||
|
@ -344,12 +357,16 @@ void GameControllerTest::createControllerSprite(ControllerHolder& holder)
|
||||||
holder._rightJoystick->setPosition(Vec2(606,293));
|
holder._rightJoystick->setPosition(Vec2(606,293));
|
||||||
holder._holderNode->addChild(holder._rightJoystick);
|
holder._holderNode->addChild(holder._rightJoystick);
|
||||||
|
|
||||||
holder._deviceIdLabel = Label::createWithTTF("Disconnected","fonts/Marker Felt.ttf",36);
|
holder._deviceLabel = Label::createWithTTF("Disconnected","fonts/Marker Felt.ttf",36);
|
||||||
holder._deviceIdLabel->setPosition(Vec2(499,460));
|
holder._deviceLabel->setPosition(Vec2(499,650));
|
||||||
holder._deviceIdLabel->setTextColor(Color4B::RED);
|
holder._deviceLabel->setTextColor(Color4B::RED);
|
||||||
holder._holderNode->addChild(holder._deviceIdLabel);
|
holder._holderNode->addChild(holder._deviceLabel);
|
||||||
|
|
||||||
|
holder._externalKeyLabel = Label::createWithTTF("Key event","fonts/Marker Felt.ttf",36);
|
||||||
|
holder._externalKeyLabel->setPosition(Vec2(499,500));
|
||||||
|
holder._externalKeyLabel->setTextColor(Color4B::RED);
|
||||||
|
holder._holderNode->addChild(holder._externalKeyLabel);
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
//371,294 64
|
|
||||||
auto dPadTexture = Director::getInstance()->getTextureCache()->addImage("dPad.png");
|
auto dPadTexture = Director::getInstance()->getTextureCache()->addImage("dPad.png");
|
||||||
|
|
||||||
auto dPadCenter = Sprite::createWithTexture(dPadTexture,Rect(60,60,68,68));
|
auto dPadCenter = Sprite::createWithTexture(dPadTexture,Rect(60,60,68,68));
|
||||||
|
@ -400,7 +417,6 @@ void GameControllerTest::createControllerSprite(ControllerHolder& holder)
|
||||||
holder._buttonR2->setPosition(Vec2(998-220,910));
|
holder._buttonR2->setPosition(Vec2(998-220,910));
|
||||||
holder._holderNode->addChild(holder._buttonR2);
|
holder._holderNode->addChild(holder._buttonR2);
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
//750 460,70
|
|
||||||
holder._buttonX = Sprite::create("X.png");
|
holder._buttonX = Sprite::create("X.png");
|
||||||
holder._buttonX->setPosition(Vec2(750 - 70,460));
|
holder._buttonX->setPosition(Vec2(750 - 70,460));
|
||||||
holder._holderNode->addChild(holder._buttonX);
|
holder._holderNode->addChild(holder._buttonX);
|
||||||
|
|
|
@ -53,7 +53,8 @@ private:
|
||||||
cocos2d::Sprite* _buttonL2;
|
cocos2d::Sprite* _buttonL2;
|
||||||
cocos2d::Sprite* _buttonR2;
|
cocos2d::Sprite* _buttonR2;
|
||||||
|
|
||||||
cocos2d::Label* _deviceIdLabel;
|
cocos2d::Label* _deviceLabel;
|
||||||
|
cocos2d::Label* _externalKeyLabel;
|
||||||
}ControllerHolder;
|
}ControllerHolder;
|
||||||
|
|
||||||
ControllerHolder _firstHolder;
|
ControllerHolder _firstHolder;
|
||||||
|
|
Loading…
Reference in New Issue