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 {
|
||||||
mKeyMap.get(keyCode), false, 0.0f, false);
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
|
|
||||||
|
mControllerEventListener.onButtonEvent(controllerDevice.getDeviceName(), controllerDevice.getDeviceId(),
|
||||||
|
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 {
|
||||||
GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
|
|
||||||
GameControllerDelegate.THUMBSTICK_LEFT_Y, y, true);
|
String deviceName = controllerDevice.getDeviceName();
|
||||||
|
int deviceId = controllerDevice.getDeviceId();
|
||||||
|
|
||||||
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
|
GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
|
||||||
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
|
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 {
|
||||||
GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
|
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
|
||||||
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
|
|
||||||
GameControllerDelegate.THUMBSTICK_RIGHT_Y, y, true);
|
String deviceName = controllerDevice.getDeviceName();
|
||||||
|
int deviceId = controllerDevice.getDeviceId();
|
||||||
|
|
||||||
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
|
GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
|
||||||
|
mControllerEventListener.onAxisEvent(deviceName, deviceId,
|
||||||
|
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,46 +16,70 @@ UIButtonTest_Editor::~UIButtonTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIButtonTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIButtonTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = Director::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
ui::Text* back_label = static_cast<ui::Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<ui::Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_123"));
|
||||||
|
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
||||||
|
|
||||||
|
Button* title_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_126"));
|
||||||
|
title_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
||||||
|
|
||||||
|
Button* scale9_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_129"));
|
||||||
|
scale9_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent,this));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UIButtonTest_Editor::init()
|
bool UIButtonTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// auto _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
|
||||||
|
|
||||||
|
|
||||||
_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();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
this->configureGUIScene();
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
_displayValueLabel = ui::Text::create();
|
||||||
|
_displayValueLabel->setFontName("Marker Felt");
|
||||||
Button* button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_123"));
|
|
||||||
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
|
||||||
|
|
||||||
Button* title_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_126"));
|
|
||||||
title_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
|
||||||
|
|
||||||
Button* scale9_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_129"));
|
|
||||||
scale9_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
|
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
|
||||||
_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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,27 +16,54 @@ UICheckBoxTest_Editor::~UICheckBoxTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UICheckBoxTest_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/UICheckBox_Editor/ui_checkbox_editor_1.json"));
|
||||||
|
_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 rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
CheckBox* checkbox = static_cast<CheckBox*>(Helper::seekWidgetByName(root, "CheckBox_540"));
|
||||||
|
checkbox->addEventListener(CC_CALLBACK_2(UICheckBoxTest_Editor::selectedStateEvent, this));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UICheckBoxTest_Editor::init()
|
bool UICheckBoxTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.csb"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.json"));
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_2.json"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
this->configureGUIScene();
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
CheckBox* checkbox = static_cast<CheckBox*>(Helper::seekWidgetByName(root, "CheckBox_540"));
|
|
||||||
checkbox->addEventListener(CC_CALLBACK_2(UICheckBoxTest_Editor::selectedStateEvent, this));
|
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create();
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
||||||
|
@ -44,7 +71,7 @@ bool UICheckBoxTest_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:
|
||||||
~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,26 +4,53 @@
|
||||||
|
|
||||||
|
|
||||||
// UIImageViewTest_Editor
|
// UIImageViewTest_Editor
|
||||||
|
void UIImageViewTest_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/UIImageView_Editor/ui_ImageView_editor_1.json"));
|
||||||
|
_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 rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UIImageViewTest_Editor::init()
|
bool UIImageViewTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.json"));
|
_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"));
|
|
||||||
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
this->configureGUIScene();
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -13,44 +13,72 @@ UILayoutTest_Editor::UILayoutTest_Editor()
|
||||||
UILayoutTest_Editor::~UILayoutTest_Editor()
|
UILayoutTest_Editor::~UILayoutTest_Editor()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Editor::init()
|
bool UILayoutTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -71,43 +99,68 @@ UILayoutTest_Color_Editor::~UILayoutTest_Color_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Color_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Color_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Color_Editor::init()
|
bool UILayoutTest_Color_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,43 +180,69 @@ UILayoutTest_Gradient_Editor::~UILayoutTest_Gradient_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Gradient_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Gradient_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Gradient_Editor::init()
|
bool UILayoutTest_Gradient_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,43 +262,70 @@ UILayoutTest_BackGroundImage_Editor::~UILayoutTest_BackGroundImage_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_BackGroundImage_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_BackGroundImage_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_BackGroundImage_Editor::init()
|
bool UILayoutTest_BackGroundImage_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,43 +345,70 @@ UILayoutTest_BackGroundImage_Scale9_Editor::~UILayoutTest_BackGroundImage_Scale9
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_BackGroundImage_Scale9_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_BackGroundImage_Scale9_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,43 +428,70 @@ UILayoutTest_Layout_Linear_Vertical_Editor::~UILayoutTest_Layout_Linear_Vertical
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Linear_Vertical_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Linear_Vertical_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,43 +511,69 @@ UILayoutTest_Layout_Linear_Horizontal_Editor::~UILayoutTest_Layout_Linear_Horizo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Linear_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Linear_Horizontal_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -408,42 +594,68 @@ UILayoutTest_Layout_Relative_Align_Parent_Editor::~UILayoutTest_Layout_Relative_
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Relative_Align_Parent_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Relative_Align_Parent_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -464,43 +676,68 @@ UILayoutTest_Layout_Relative_Location_Editor::~UILayoutTest_Layout_Relative_Loca
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Relative_Location_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILayoutTest_Layout_Relative_Location_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
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,47 +15,73 @@ UIListViewTest_Vertical_Editor::~UIListViewTest_Vertical_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIListViewTest_Vertical_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_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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIListViewTest_Vertical_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
// ListView* listView = static_cast<ListView*>(UIHelper::seekWidgetByName(root, "ListView_1214"));
|
||||||
|
// CCLOG("listView isBounceEnabled = %d", listView->isBounceEnabled());
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
|
||||||
|
|
||||||
|
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UIListViewTest_Vertical_Editor::init()
|
bool UIListViewTest_Vertical_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
// ListView* listView = static_cast<ListView*>(UIHelper::seekWidgetByName(root, "ListView_1214"));
|
|
||||||
// CCLOG("listView isBounceEnabled = %d", listView->isBounceEnabled());
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
|
|
||||||
|
|
||||||
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +98,61 @@ 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);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.csb"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIListViewTest_Horizontal_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
UIListViewTest_Horizontal_Editor::~UIListViewTest_Horizontal_Editor()
|
UIListViewTest_Horizontal_Editor::~UIListViewTest_Horizontal_Editor()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -81,38 +162,10 @@ bool UIListViewTest_Horizontal_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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()->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"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
this->configureGUIScene();
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
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,34 +16,60 @@ UILoadingBarTest_Editor::~UILoadingBarTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UILoadingBarTest_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/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}else{
|
||||||
|
_layout->removeFromParentAndCleanup(true);
|
||||||
|
|
||||||
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.csb"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UILoadingBarTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
LoadingBar* loadingBar_left_to_right = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_856"));
|
||||||
|
loadingBar_left_to_right->setPercent(0);
|
||||||
|
|
||||||
|
LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_857"));
|
||||||
|
loadingBar_right_to_left->setPercent(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UILoadingBarTest_Editor::init()
|
bool UILoadingBarTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
scheduleUpdate();
|
scheduleUpdate();
|
||||||
|
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
|
_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"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
LoadingBar* loadingBar_left_to_right = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_856"));
|
|
||||||
loadingBar_left_to_right->setPercent(0);
|
|
||||||
|
|
||||||
LoadingBar* loadingBar_right_to_left = dynamic_cast<LoadingBar*>(Helper::seekWidgetByName(root, "LoadingBar_857"));
|
|
||||||
loadingBar_right_to_left->setPercent(0);
|
|
||||||
|
|
||||||
|
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,43 +16,70 @@ UIPageViewTest_Editor::~UIPageViewTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIPageViewTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIPageViewTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UIPageViewTest_Editor::init()
|
bool UIPageViewTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
|
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,43 +15,70 @@ UIScrollViewTest_Vertical_Editor::~UIScrollViewTest_Vertical_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Vertical_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Vertical_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UIScrollViewTest_Vertical_Editor::init()
|
bool UIScrollViewTest_Vertical_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,45 +96,72 @@ UIScrollViewTest_Horizontal_Editor::UIScrollViewTest_Horizontal_Editor()
|
||||||
UIScrollViewTest_Horizontal_Editor::~UIScrollViewTest_Horizontal_Editor()
|
UIScrollViewTest_Horizontal_Editor::~UIScrollViewTest_Horizontal_Editor()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Horizontal_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UIScrollViewTest_Horizontal_Editor::init()
|
bool UIScrollViewTest_Horizontal_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,43 +181,68 @@ UIScrollViewTest_Both_Editor::~UIScrollViewTest_Both_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Both_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIScrollViewTest_Both_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
Button* left_button = Button::create();
|
||||||
|
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
||||||
|
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
||||||
|
left_button->getContentSize().height * 0.625));
|
||||||
|
left_button->setTouchEnabled(true);
|
||||||
|
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
||||||
|
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(left_button);
|
||||||
|
|
||||||
|
Button* right_button = Button::create();
|
||||||
|
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
||||||
|
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
||||||
|
right_button->getContentSize().height * 0.625));
|
||||||
|
right_button->setTouchEnabled(true);
|
||||||
|
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
||||||
|
_layout->addChild(right_button);
|
||||||
|
}
|
||||||
|
|
||||||
bool UIScrollViewTest_Both_Editor::init()
|
bool UIScrollViewTest_Both_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_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"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.json"));
|
||||||
_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);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
Button* left_button = Button::create();
|
|
||||||
left_button->loadTextures("Images/b1.png", "Images/b2.png", "");
|
|
||||||
left_button->setPosition(Vec2(_layout->getContentSize().width / 2 - left_button->getContentSize().width,
|
|
||||||
left_button->getContentSize().height * 0.625));
|
|
||||||
left_button->setTouchEnabled(true);
|
|
||||||
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
|
|
||||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(left_button);
|
|
||||||
|
|
||||||
Button* right_button = Button::create();
|
|
||||||
right_button->loadTextures("Images/f1.png", "Images/f2.png", "");
|
|
||||||
right_button->setPosition(Vec2(_layout->getContentSize().width / 2 + right_button->getContentSize().width,
|
|
||||||
right_button->getContentSize().height * 0.625));
|
|
||||||
right_button->setTouchEnabled(true);
|
|
||||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
|
|
||||||
_layout->addChild(right_button);
|
|
||||||
|
|
||||||
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,32 +16,58 @@ UISliderTest_Editor::~UISliderTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UISliderTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UISliderTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
|
||||||
|
Slider* slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_738"));
|
||||||
|
slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
||||||
|
|
||||||
|
Slider* scale9_slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_740"));
|
||||||
|
scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
||||||
|
}
|
||||||
|
|
||||||
bool UISliderTest_Editor::init()
|
bool UISliderTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
|
||||||
Slider* slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_738"));
|
|
||||||
slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
|
||||||
|
|
||||||
Slider* scale9_slider = static_cast<Slider*>(Helper::seekWidgetByName(root, "Slider_740"));
|
|
||||||
scale9_slider->addEventListener(CC_CALLBACK_2(UISliderTest_Editor::sliderEvent, this));
|
|
||||||
|
|
||||||
|
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,26 +3,51 @@
|
||||||
#include "UITextAtlasTest_Editor.h"
|
#include "UITextAtlasTest_Editor.h"
|
||||||
|
|
||||||
// UITextAtlasTest_Editor
|
// UITextAtlasTest_Editor
|
||||||
|
void UITextAtlasTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextAtlasTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextAtlasTest_Editor::init()
|
bool UITextAtlasTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
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,26 +4,51 @@
|
||||||
|
|
||||||
|
|
||||||
// UITextBMFontTest_Editor
|
// UITextBMFontTest_Editor
|
||||||
|
void UITextBMFontTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextBMFontTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextBMFontTest_Editor::init()
|
bool UITextBMFontTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
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,33 +16,60 @@ UITextFieldTest_Editor::~UITextFieldTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UITextFieldTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextFieldTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
TextField* textField_normal = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1109"));
|
||||||
|
textField_normal->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
||||||
|
|
||||||
|
TextField* textField_max_character = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1110"));
|
||||||
|
textField_max_character->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
||||||
|
|
||||||
|
TextField* textField_password = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1107"));
|
||||||
|
textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextFieldTest_Editor::init()
|
bool UITextFieldTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
this->configureGUIScene();
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
TextField* textField_normal = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1109"));
|
|
||||||
textField_normal->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
|
||||||
|
|
||||||
TextField* textField_max_character = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1110"));
|
|
||||||
textField_max_character->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
|
||||||
|
|
||||||
TextField* textField_password = static_cast<TextField*>(Helper::seekWidgetByName(root, "TextField_1107"));
|
|
||||||
textField_password->addEventListener(CC_CALLBACK_2(UITextFieldTest_Editor::textFieldEvent, this));
|
|
||||||
|
|
||||||
_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,25 +7,51 @@
|
||||||
// UITextTest_Editor
|
// UITextTest_Editor
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
|
|
||||||
|
void UITextTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UITextTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool UITextTest_Editor::init()
|
bool UITextTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
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,35 +15,63 @@ UIWidgetAddNodeTest_Editor::~UIWidgetAddNodeTest_Editor()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UIWidgetAddNodeTest_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/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"));
|
||||||
|
_touchGroup->addChild(_layout);
|
||||||
|
|
||||||
|
this->configureGUIScene();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UIWidgetAddNodeTest_Editor::configureGUIScene()
|
||||||
|
{
|
||||||
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
Size rootSize = _layout->getContentSize();
|
||||||
|
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
||||||
|
(screenSize.height - rootSize.height) / 2));
|
||||||
|
|
||||||
|
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
||||||
|
|
||||||
|
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
||||||
|
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
||||||
|
|
||||||
|
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
||||||
|
|
||||||
|
|
||||||
|
// Create the ui widget
|
||||||
|
Widget* widget = Widget::create();
|
||||||
|
widget->setPosition(Vec2(rootSize.width / 2.0f, rootSize.height / 2.0f));
|
||||||
|
widget->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||||
|
_layout->addChild(widget);
|
||||||
|
|
||||||
|
Sprite* sprite = Sprite::create("cocosui/ccicon.png");
|
||||||
|
widget->addChild(sprite);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UIWidgetAddNodeTest_Editor::init()
|
bool UIWidgetAddNodeTest_Editor::init()
|
||||||
{
|
{
|
||||||
if (UIScene_Editor::init())
|
if (UIScene_Editor::init())
|
||||||
{
|
{
|
||||||
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
|
||||||
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb"));
|
|
||||||
_touchGroup->addChild(_layout);
|
_touchGroup->addChild(_layout);
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
this->configureGUIScene();
|
||||||
Size rootSize = _layout->getContentSize();
|
|
||||||
_touchGroup->setPosition(Vec2((screenSize.width - rootSize.width) / 2,
|
|
||||||
(screenSize.height - rootSize.height) / 2));
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
|
|
||||||
|
|
||||||
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
|
|
||||||
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
|
|
||||||
|
|
||||||
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
|
|
||||||
|
|
||||||
|
|
||||||
// Create the ui widget
|
|
||||||
Widget* widget = Widget::create();
|
|
||||||
widget->setPosition(Vec2(rootSize.width / 2.0f, rootSize.height / 2.0f));
|
|
||||||
widget->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
|
||||||
_layout->addChild(widget);
|
|
||||||
|
|
||||||
Sprite* sprite = Sprite::create("cocosui/ccicon.png");
|
|
||||||
widget->addChild(sprite);
|
|
||||||
|
|
||||||
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,7 +197,12 @@ 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:
|
||||||
break;
|
{
|
||||||
|
char ketStatus[30];
|
||||||
|
sprintf(ketStatus,"Key Down:%d",keyCode);
|
||||||
|
holder->_externalKeyLabel->setString(ketStatus);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -231,7 +240,12 @@ void GameControllerTest::showButtonState(cocos2d::Controller *controller, int ke
|
||||||
holder->_buttonR1->setColor(Color3B::WHITE);
|
holder->_buttonR1->setColor(Color3B::WHITE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
{
|
||||||
|
char ketStatus[30];
|
||||||
|
sprintf(ketStatus,"Key Up:%d",keyCode);
|
||||||
|
holder->_externalKeyLabel->setString(ketStatus);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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