Merge branch 'newcode' into v3

This commit is contained in:
yangxiao 2014-07-08 11:19:26 +08:00
commit b19ca902ce
81 changed files with 2686 additions and 903 deletions

View File

@ -886,6 +886,7 @@ Developers:
zhouxiaoxiaoxujian
Added TextField::getStringLength()
Add shadow, outline, glow filter support for UIText
Fix UITextField IME can't auto detach
QiuleiWang
Fix the bug that calculated height of multi-line string was incorrect on iOS

View File

@ -1,4 +1,8 @@
cocos2d-x-3.2rc0 ??
cocos2d-x-3.2 ??
[FIX] Label: color can not be set correctly if using system font
[FIX] UITextField: keyboard can not hide if touching space outside of keyboard
cocos2d-x-3.2rc0 Jul.7 2014
[NEW] FastTMXTiledMap: added fast tmx, which is much more faster for static tiled map
[NEW] GLProgramState: can use uniform location to get/set uniform values
[NEW] HttpClient: added sendImmediate()

View File

@ -133,6 +133,11 @@ bool LabelAtlas::initWithString(const std::string& theString, const std::string&
//CCLabelAtlas - Atlas generation
void LabelAtlas::updateAtlasValues()
{
if(_itemsPerRow == 0)
{
return;
}
ssize_t n = _string.length();
const unsigned char *s = (unsigned char*)_string.c_str();

View File

@ -1305,6 +1305,9 @@ Mat4 Node::transform(const Mat4& parentTransform)
void Node::onEnter()
{
if (_onEnterCallback)
_onEnterCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
@ -1332,6 +1335,9 @@ void Node::onEnter()
void Node::onEnterTransitionDidFinish()
{
if (_onEnterTransitionDidFinishCallback)
_onEnterTransitionDidFinishCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
@ -1354,6 +1360,9 @@ void Node::onEnterTransitionDidFinish()
void Node::onExitTransitionDidStart()
{
if (_onExitTransitionDidStartCallback)
_onExitTransitionDidStartCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{
@ -1375,6 +1384,9 @@ void Node::onExitTransitionDidStart()
void Node::onExit()
{
if (_onExitCallback)
_onExitCallback();
#if CC_ENABLE_SCRIPT_BINDING
if (_scriptType == kScriptTypeJavascript)
{

View File

@ -1466,7 +1466,16 @@ public:
virtual void setOpacityModifyRGB(bool value) {CC_UNUSED_PARAM(value);}
virtual bool isOpacityModifyRGB() const { return false; };
void setOnEnterCallback(const std::function<void()>& callback) { _onEnterCallback = callback; }
const std::function<void()>& getOnEnterCallback() const { return _onEnterCallback; }
void setOnExitCallback(const std::function<void()>& callback) { _onExitCallback = callback; }
const std::function<void()>& getOnExitCallback() const { return _onExitCallback; }
void setonEnterTransitionDidFinishCallback(const std::function<void()>& callback) { _onEnterTransitionDidFinishCallback = callback; }
const std::function<void()>& getonEnterTransitionDidFinishCallback() const { return _onEnterTransitionDidFinishCallback; }
void setonExitTransitionDidStartCallback(const std::function<void()>& callback) { _onExitTransitionDidStartCallback = callback; }
const std::function<void()>& getonExitTransitionDidStartCallback() const { return _onExitTransitionDidStartCallback; }
CC_CONSTRUCTOR_ACCESS:
// Nodes should be created using create();
Node();
@ -1605,6 +1614,11 @@ protected:
static int s_globalOrderOfArrival;
std::function<void()> _onEnterCallback;
std::function<void()> _onExitCallback;
std::function<void()> _onEnterTransitionDidFinishCallback;
std::function<void()> _onExitTransitionDidStartCallback;
private:
CC_DISALLOW_COPY_AND_ASSIGN(Node);

View File

@ -7,7 +7,7 @@
<PropertyGroup />
<ItemDefinitionGroup>
<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>
<CompileAsWinRT>true</CompileAsWinRT>
<MultiProcessorCompilation>true</MultiProcessorCompilation>

View File

@ -47,6 +47,7 @@ typedef SSIZE_T ssize_t;
#include <mutex>
#include <stdarg.h>
#include "base/CCRef.h"
#include "base/ccMacros.h"
#include "base/CCPlatformMacros.h"
@ -73,6 +74,7 @@ void CC_DLL log(const char * format, ...) CC_FORMAT_PRINTF(1, 2);
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
class CC_DLL Console
: public Ref
{
public:
struct Command {

View File

@ -47,18 +47,19 @@ public:
auto iter = std::find_if(Controller::s_allController.begin(), Controller::s_allController.end(), [&](Controller* controller){
return (deviceName == controller->_deviceName) && (deviceId == controller->_deviceId);
});
return iter;
}
static void onConnected(const std::string& deviceName, int deviceId)
{
// 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);
if (iter != Controller::s_allController.end())
return;
log("onConnected new device");
// It's a new controller being connected.
auto controller = new cocos2d::Controller();
controller->_deviceId = deviceId;
@ -70,11 +71,11 @@ public:
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);
if (iter == Controller::s_allController.end())
{
log("Could not find the controller!");
CCLOGERROR("Could not find the controller!");
return;
}
@ -85,11 +86,10 @@ public:
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);
if (iter == Controller::s_allController.end())
{
log("onButtonEvent new connect");
CCLOG("onButtonEvent:connect new controller.");
onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
}
@ -102,10 +102,11 @@ public:
auto iter = findController(deviceName, deviceId);
if (iter == Controller::s_allController.end())
{
CCLOG("onAxisEvent:connect new controller.");
onConnected(deviceName, deviceId);
iter = findController(deviceName, deviceId);
}
(*iter)->onAxisEvent(axisCode, value, isAnalog);
}
@ -154,6 +155,16 @@ Controller::Controller()
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
extern "C" {

View File

@ -311,6 +311,10 @@ bool Controller::isConnected() const
return _impl->_gcController.isAttachedToDevice == YES;
}
void Controller::receiveExternalKeyEvent(int externalKeyCode,bool receive)
{
}
NS_CC_END
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

View File

@ -99,6 +99,15 @@ public:
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;}
int getTag() const { return _controllerTag;}

View File

@ -46,6 +46,7 @@ Ref::Ref()
static unsigned int uObjectCount = 0;
_luaID = 0;
_ID = ++uObjectCount;
_scriptObject = nullptr;
#endif
#if CC_USE_MEM_LEAK_DETECTION

View File

@ -142,6 +142,8 @@ public:
unsigned int _ID;
/// Lua reference id
int _luaID;
/// scriptObject, support for swift
void* _scriptObject;
#endif
// Memory leak diagnostic data (only included when CC_USE_MEM_LEAK_DETECTION is defined and its value isn't zero)

View File

@ -202,9 +202,6 @@ Only valid for cocos2d-mac. Not supported on cocos2d-ios.
0 -- disabled
1 -- draw bounding box
2 -- draw texture box
0 -- disabled
1 -- draw bounding box
2 -- draw texture box
*/
#ifndef CC_SPRITE_DEBUG_DRAW
#define CC_SPRITE_DEBUG_DRAW 0

View File

@ -33,6 +33,7 @@ THE SOFTWARE.
#include "math/CCGeometry.h"
#include "math/CCMath.h"
#include "CCGL.h"
#include "CCRef.h"
NS_CC_BEGIN
@ -484,6 +485,7 @@ public:
@brief The device accelerometer reports values for each axis in units of g-force
*/
class Acceleration
: public Ref
{
public:
double x;

View File

@ -31,7 +31,7 @@ NS_CC_BEGIN
const char* cocos2dVersion()
{
return "cocos2d-x 3.2alpha0";
return "cocos2d-x 3.2beta0";
}
NS_CC_END

View File

@ -303,12 +303,10 @@ void NodeReader::initNode(Node* node, const rapidjson::Value& json)
if(alpha != 255)
{
node->setOpacity(alpha);
node->setCascadeOpacityEnabled(true);
}
if(red != 255 || green != 255 || blue != 255)
{
node->setColor(Color3B(red, green, blue));
node->setCascadeColorEnabled(true);
}

View File

@ -49,7 +49,7 @@ namespace cocostudio
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) {
@ -70,11 +70,7 @@ namespace cocostudio
label->setFontSize(valueToInt(value));
}else if(key == P_FontName){
std::string fontFilePath;
if(FileUtils::getInstance()->isFileExist(value)){
fontFilePath = jsonPath.append(value);
}else{
fontFilePath = value;
}
fontFilePath = binaryFilePath.append(value);
label->setFontName(fontFilePath);
}else if(key == P_AreaWidth){
label->setTextAreaSize(Size(valueToFloat(value), label->getTextAreaSize().height));

View File

@ -114,8 +114,10 @@ namespace cocostudio
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->setPositionType((Widget::PositionType)DICTOOL->getIntValue_json(options, P_PositionType));

View File

@ -77,7 +77,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<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>
<DisableSpecificWarnings>4267;4251;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalOptions>/Zm200 %(AdditionalOptions)</AdditionalOptions>

View File

@ -31,11 +31,9 @@ import org.cocos2dx.lib.inputmanagercompat.InputManagerCompat.InputDeviceListene
import org.cocos2dx.lib.Cocos2dxActivity;
import android.os.Bundle;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.util.Log;
import android.util.SparseArray;
public abstract class GameControllerActivity extends Cocos2dxActivity implements InputDeviceListener {
// ===========================================================
@ -224,30 +222,11 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
return handled || super.dispatchGenericMotionEvent(event);
}
protected SparseArray<String> mGameController = null;
@Override
public void onInputDeviceAdded(int deviceId) {
Log.d(TAG,"onInputDeviceAdded:" + 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) )
{
if (mGameController == null) {
mGameController = new SparseArray<String>();
}
String deviceName = device.getName();
mGameController.append(deviceId, deviceName);
GameControllerAdapter.onConnected(deviceName, deviceId);
}
} catch (Exception e) {
e.printStackTrace();
}
mControllerHelper.onInputDeviceAdded(deviceId);
}
/*
* 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) {
Log.d(TAG,"onInputDeviceRemoved:" + deviceId);
if (mGameController != null && mGameController.get(deviceId) != null) {
GameControllerAdapter.onDisconnected(mGameController.get(deviceId), deviceId);
mGameController.delete(deviceId);
}
mControllerHelper.onInputDeviceRemoved(deviceId);
}
@Override
@ -293,8 +269,10 @@ public abstract class GameControllerActivity extends Cocos2dxActivity implements
if (mControllerOuya != null) {
mControllerOuya.onResume();
}
mControllerHelper.gatherControllers();
}
@Override
protected void onPause() {
if (mControllerNibiru != null) {

View File

@ -1,6 +1,8 @@
package org.cocos2dx.lib;
import android.util.Log;
import java.util.ArrayList;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.InputDevice;
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_SELECT, GameControllerDelegate.BUTTON_SELECT);
//KEYCODE_BUTTON_MODE
}
private float mOldLeftThumbstickX = 0.0f;
@ -76,68 +77,71 @@ public class GameControllerHelper {
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) )
{
if (event.getAction() == MotionEvent.ACTION_MOVE) {
int devicedId = event.getDeviceId();
int deviceId = event.getDeviceId();
String deviceName = event.getDevice().getName();
if(mGameController.get(deviceId) == null){
mGameController.append(deviceId, deviceName);
}
float newAXIS_LX = event.getAxisValue(AXIS_X);
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;
handled = true;
}
float newAXIS_LY = event.getAxisValue(AXIS_Y);
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;
handled = true;
}
float newAXIS_RX = event.getAxisValue(AXIS_Z);
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;
handled = true;
}
float newAXIS_RY = event.getAxisValue(AXIS_RZ);
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;
handled = true;
}
float newAXIS_LTRIGGER = event.getAxisValue(AXIS_LTRIGGER);
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;
handled = true;
}
float newAXIS_RTRIGGER = event.getAxisValue(AXIS_RTRIGGER);
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;
handled = true;
}
float newAXIS_BRAKE = event.getAxisValue(AXIS_BRAKE);
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;
handled = true;
}
float newAXIS_THROTTLE = event.getAxisValue(AXIS_THROTTLE);
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;
handled = true;
}
float newAXIS_GAS = event.getAxisValue(AXIS_GAS);
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;
handled = true;
}
@ -147,6 +151,8 @@ public class GameControllerHelper {
return handled;
}
private static SparseArray<ArrayList<Integer>> mControllerExtendKey = new SparseArray<ArrayList<Integer>>();
public boolean dispatchKeyEvent(KeyEvent event) {
boolean handled = false;
@ -154,19 +160,96 @@ public class GameControllerHelper {
int keyCode = event.getKeyCode();
int controllerKey = ControllerKeyMap.get(keyCode);
if (controllerKey != 0 && (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|| ((eventSource & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK) ))
if (((eventSource & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|| ((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();
if (action == KeyEvent.ACTION_DOWN) {
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) {
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;
}
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();
}
}
}
}

View File

@ -27,7 +27,6 @@ public class GameControllerNibiru implements OnControllerSeviceListener, OnKeyLi
OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameControllerDelegate {
private static final String TAG = "NibiruTag";
private static final String mVendorName = "Nibiru";
private Context mContext;
private SparseIntArray mKeyMap;
@ -132,7 +131,14 @@ OnSimpleStickListener, OnAccListener, OnGyroListener, OnStateListener, GameContr
}
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) {
mControllerEventListener.onButtonEvent(mVendorName, playerOrder,
mKeyMap.get(keyCode), false, 0.0f, false);
try {
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
mControllerEventListener.onButtonEvent(controllerDevice.getDeviceName(), controllerDevice.getDeviceId(),
mKeyMap.get(keyCode), false, 0.0f, false);
} catch (ControllerServiceException e) {
e.printStackTrace();
}
}
}
@Override
public void onLeftStickChanged(int playerOrder, float x, float y) {
if (mControllerEventListener != null) {
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
GameControllerDelegate.THUMBSTICK_LEFT_X, x, true);
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
GameControllerDelegate.THUMBSTICK_LEFT_Y, y, true);
try {
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
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
public void onRightStickChanged(int playerOrder, float x, float y) {
if (mControllerEventListener != null) {
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
GameControllerDelegate.THUMBSTICK_RIGHT_X, x, true);
mControllerEventListener.onAxisEvent(mVendorName, playerOrder,
GameControllerDelegate.THUMBSTICK_RIGHT_Y, y, true);
try {
ControllerDevice controllerDevice = mControllerService.getDeviceByPlayerOrder(playerOrder);
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 (state == ControllerDevice.STATE_CONN)
{
mControllerEventListener.onConnected(mVendorName, playerOrder);
mControllerEventListener.onConnected(device.getDeviceName(), device.getDeviceId());
}
else if (state == ControllerDevice.STATE_DISCONN)
{
mControllerEventListener.onDisconnected(mVendorName, playerOrder);
mControllerEventListener.onDisconnected(device.getDeviceName(), device.getDeviceId());
}
}
}

View File

@ -10,8 +10,6 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
public class GameControllerOuya implements GameControllerDelegate{
public static final String sVendorName = "Ouya";
private SparseIntArray mKeyMap;
@ -61,27 +59,28 @@ public class GameControllerOuya implements GameControllerDelegate{
if (handled && mControllerEventListener != null)
{
OuyaController c = OuyaController.getControllerByDeviceId(event.getDeviceId());
int controllerID = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
int deviceId = event.getDeviceId();
String deviceName = event.getDevice().getName();
OuyaController c = OuyaController.getControllerByDeviceId(deviceId);
float newLeftTrigger = c.getAxisValue(OuyaController.AXIS_L2);
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;
}
float newRightTrigger = c.getAxisValue(OuyaController.AXIS_R2);
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;
}
float newLeftThumbstickX = c.getAxisValue(OuyaController.AXIS_LS_X);
if (Float.compare(newLeftThumbstickX, mOldLeftThumbstickX) != 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 {
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_X, newLeftThumbstickX, true);
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_X, newLeftThumbstickX, true);
}
mOldLeftThumbstickX = newLeftThumbstickX;
}
@ -89,9 +88,9 @@ public class GameControllerOuya implements GameControllerDelegate{
float newLeftThumbstickY = c.getAxisValue(OuyaController.AXIS_LS_Y);
if (Float.compare(newLeftThumbstickY, mOldLeftThumbstickY) != 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 {
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_LEFT_Y, newLeftThumbstickY, true);
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_LEFT_Y, newLeftThumbstickY, true);
}
mOldLeftThumbstickY = newLeftThumbstickY;
}
@ -99,9 +98,9 @@ public class GameControllerOuya implements GameControllerDelegate{
float newRightThumbstickX = c.getAxisValue(OuyaController.AXIS_RS_X);
if (Float.compare(newRightThumbstickX, mOldRightThumbstickX) != 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 {
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_X, newRightThumbstickX, true);
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_X, newRightThumbstickX, true);
}
mOldRightThumbstickX = newRightThumbstickX;
}
@ -109,9 +108,9 @@ public class GameControllerOuya implements GameControllerDelegate{
float newRightThumbstickY = c.getAxisValue(OuyaController.AXIS_RS_Y);
if (Float.compare(newRightThumbstickY, mOldRightThumbstickY) != 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 {
mControllerEventListener.onAxisEvent(sVendorName, controllerID, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newRightThumbstickY, true);
mControllerEventListener.onAxisEvent(deviceName, deviceId, GameControllerDelegate.THUMBSTICK_RIGHT_Y, newRightThumbstickY, true);
}
mOldRightThumbstickY = newRightThumbstickY;
}
@ -122,9 +121,14 @@ public class GameControllerOuya implements GameControllerDelegate{
public boolean dispatchKeyEvent(KeyEvent event) {
boolean handled = false;
int action = event.getAction();
int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_BUTTON_L2 || keyCode == KeyEvent.KEYCODE_BUTTON_R2) {
return true;
}
if (action == KeyEvent.ACTION_DOWN) {
handled = OuyaController.onKeyDown(keyCode, event);
}
@ -139,11 +143,10 @@ public class GameControllerOuya implements GameControllerDelegate{
isAnalog = true;
}
int controllerID = OuyaController.getPlayerNumByDeviceId(event.getDeviceId());
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 {
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);
}
}

View File

@ -348,7 +348,7 @@ static bool _initWithString(const char * text, cocos2d::Device::TextAlign align,
}
// text color
CGContextSetRGBFillColor(context, info->tintColorR, info->tintColorG, info->tintColorB, 1);
CGContextSetRGBFillColor(context, info->tintColorR / 255.0f, info->tintColorG / 255.0f, info->tintColorB / 255.0f, 1);
// move Y rendering to the top of the image
CGContextTranslateCTM(context, 0.0f, (dim.height - shadowStrokePaddingY) );
CGContextScaleCTM(context, 1.0f, -1.0f); //NOTE: NSString draws in UIKit referential i.e. renders upside-down compared to CGBitmapContext referential

View File

@ -393,7 +393,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
if (isKeyboardShown_)
{
[self handleTouchesAfterKeyboardShow];
return;
}
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
@ -414,10 +413,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if (isKeyboardShown_)
{
return;
}
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
@ -436,11 +431,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (isKeyboardShown_)
{
return;
}
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};
@ -459,11 +449,6 @@ Copyright (C) 2008 Apple Inc. All Rights Reserved.
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
if (isKeyboardShown_)
{
return;
}
UITouch* ids[IOS_MAX_TOUCHES_COUNT] = {0};
float xs[IOS_MAX_TOUCHES_COUNT] = {0.0f};
float ys[IOS_MAX_TOUCHES_COUNT] = {0.0f};

View File

@ -711,7 +711,7 @@ std::string Texture2D::getDescription() const
// implementation Texture2D (Image)
bool Texture2D::initWithImage(Image *image)
{
return initWithImage(image, image->getRenderFormat());
return initWithImage(image, PixelFormat::NONE);
}
bool Texture2D::initWithImage(Image *image, PixelFormat format)

View File

@ -1,6 +1,7 @@
--------------------------------
-- @module Console
-- @extend Ref
-- @parent_module cc
--------------------------------

View File

@ -59,6 +59,11 @@
-- @param self
-- @return array_table#array_table ret (retunr value: array_table)
--------------------------------
-- @function [parent=#Node] setOnExitCallback
-- @param self
-- @param #function func
--------------------------------
-- @function [parent=#Node] pause
-- @param self
@ -110,6 +115,11 @@
-- @param self
-- @param #float float
--------------------------------
-- @function [parent=#Node] setonEnterTransitionDidFinishCallback
-- @param self
-- @param #function func
--------------------------------
-- @function [parent=#Node] removeAllComponents
-- @param self
@ -124,6 +134,11 @@
-- @param self
-- @return int#int ret (return value: int)
--------------------------------
-- @function [parent=#Node] getonEnterTransitionDidFinishCallback
-- @param self
-- @return function#function ret (return value: function)
--------------------------------
-- @function [parent=#Node] getGLProgram
-- @param self
@ -171,6 +186,11 @@
-- @param self
-- @param #cc.GLProgramState glprogramstate
--------------------------------
-- @function [parent=#Node] setOnEnterCallback
-- @param self
-- @param #function func
--------------------------------
-- @function [parent=#Node] getOpacity
-- @param self
@ -181,6 +201,11 @@
-- @param self
-- @param #vec2_table vec2
--------------------------------
-- @function [parent=#Node] setonExitTransitionDidStartCallback
-- @param self
-- @param #function func
--------------------------------
-- @function [parent=#Node] convertTouchToNodeSpace
-- @param self
@ -232,6 +257,11 @@
-- @param #cc.Touch touch
-- @return vec2_table#vec2_table ret (return value: vec2_table)
--------------------------------
-- @function [parent=#Node] getOnEnterCallback
-- @param self
-- @return function#function ret (return value: function)
--------------------------------
-- @function [parent=#Node] convertToNodeSpace
-- @param self
@ -540,6 +570,11 @@
-- @param #float float
-- @param #float float
--------------------------------
-- @function [parent=#Node] getOnExitCallback
-- @param self
-- @return function#function ret (return value: function)
--------------------------------
-- @function [parent=#Node] getChildByTag
-- @param self
@ -643,6 +678,11 @@
-- @param #string str
-- @param #function func
--------------------------------
-- @function [parent=#Node] getonExitTransitionDidStartCallback
-- @param self
-- @return function#function ret (return value: function)
--------------------------------
-- overload function: removeFromParentAndCleanup(bool)
--

View File

@ -353,7 +353,7 @@ static int lua_cocos2dx_Console_finalize(lua_State* tolua_S)
int lua_register_cocos2dx_Console(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"cc.Console");
tolua_cclass(tolua_S,"Console","cc.Console","",nullptr);
tolua_cclass(tolua_S,"Console","cc.Console","cc.Ref",nullptr);
tolua_beginmodule(tolua_S,"Console");
tolua_function(tolua_S,"stop",lua_cocos2dx_Console_stop);
@ -4031,6 +4031,56 @@ int lua_cocos2dx_Node_getChildren(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_setOnExitCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setOnExitCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void ()> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
return 0;
cobj->setOnExitCallback(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOnExitCallback",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setOnExitCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_pause(lua_State* tolua_S)
{
int argc = 0;
@ -4488,6 +4538,56 @@ int lua_cocos2dx_Node_setRotationSkewX(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_setonEnterTransitionDidFinishCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setonEnterTransitionDidFinishCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void ()> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
return 0;
cobj->setonEnterTransitionDidFinishCallback(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setonEnterTransitionDidFinishCallback",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setonEnterTransitionDidFinishCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_removeAllComponents(lua_State* tolua_S)
{
int argc = 0;
@ -4621,6 +4721,50 @@ int lua_cocos2dx_Node_getTag(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_getonEnterTransitionDidFinishCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getonEnterTransitionDidFinishCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::function<void ()>& ret = cobj->getonEnterTransitionDidFinishCallback();
#pragma warning NO CONVERSION FROM NATIVE FOR std::function;
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getonEnterTransitionDidFinishCallback",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getonEnterTransitionDidFinishCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_getGLProgram(lua_State* tolua_S)
{
int argc = 0;
@ -5039,6 +5183,56 @@ int lua_cocos2dx_Node_setGLProgramState(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_setOnEnterCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setOnEnterCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void ()> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
return 0;
cobj->setOnEnterCallback(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setOnEnterCallback",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setOnEnterCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_getOpacity(lua_State* tolua_S)
{
int argc = 0;
@ -5129,6 +5323,56 @@ int lua_cocos2dx_Node_setNormalizedPosition(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_setonExitTransitionDidStartCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_setonExitTransitionDidStartCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::function<void ()> arg0;
do {
// Lambda binding for lua is not supported.
assert(false);
} while(0)
;
if(!ok)
return 0;
cobj->setonExitTransitionDidStartCallback(arg0);
return 0;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setonExitTransitionDidStartCallback",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_setonExitTransitionDidStartCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_convertTouchToNodeSpace(lua_State* tolua_S)
{
int argc = 0;
@ -5538,6 +5782,50 @@ int lua_cocos2dx_Node_convertTouchToNodeSpaceAR(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_getOnEnterCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getOnEnterCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::function<void ()>& ret = cobj->getOnEnterCallback();
#pragma warning NO CONVERSION FROM NATIVE FOR std::function;
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOnEnterCallback",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getOnEnterCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_convertToNodeSpace(lua_State* tolua_S)
{
int argc = 0;
@ -8091,6 +8379,50 @@ int lua_cocos2dx_Node_setScale(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_getOnExitCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getOnExitCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::function<void ()>& ret = cobj->getOnExitCallback();
#pragma warning NO CONVERSION FROM NATIVE FOR std::function;
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOnExitCallback",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getOnExitCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_getChildByTag(lua_State* tolua_S)
{
int argc = 0;
@ -8966,6 +9298,50 @@ int lua_cocos2dx_Node_enumerateChildren(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_Node_getonExitTransitionDidStartCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Node* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_getonExitTransitionDidStartCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
return 0;
const std::function<void ()>& ret = cobj->getonExitTransitionDidStartCallback();
#pragma warning NO CONVERSION FROM NATIVE FOR std::function;
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getonExitTransitionDidStartCallback",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_getonExitTransitionDidStartCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_Node_removeFromParentAndCleanup(lua_State* tolua_S)
{
int argc = 0;
@ -9604,6 +9980,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
tolua_function(tolua_S,"setOpacityModifyRGB",lua_cocos2dx_Node_setOpacityModifyRGB);
tolua_function(tolua_S,"setCascadeOpacityEnabled",lua_cocos2dx_Node_setCascadeOpacityEnabled);
tolua_function(tolua_S,"getChildren",lua_cocos2dx_Node_getChildren);
tolua_function(tolua_S,"setOnExitCallback",lua_cocos2dx_Node_setOnExitCallback);
tolua_function(tolua_S,"pause",lua_cocos2dx_Node_pause);
tolua_function(tolua_S,"convertToWorldSpaceAR",lua_cocos2dx_Node_convertToWorldSpaceAR);
tolua_function(tolua_S,"isIgnoreAnchorPointForPosition",lua_cocos2dx_Node_isIgnoreAnchorPointForPosition);
@ -9614,9 +9991,11 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
tolua_function(tolua_S,"setScaleY",lua_cocos2dx_Node_setScaleY);
tolua_function(tolua_S,"setScaleX",lua_cocos2dx_Node_setScaleX);
tolua_function(tolua_S,"setRotationSkewX",lua_cocos2dx_Node_setRotationSkewX);
tolua_function(tolua_S,"setonEnterTransitionDidFinishCallback",lua_cocos2dx_Node_setonEnterTransitionDidFinishCallback);
tolua_function(tolua_S,"removeAllComponents",lua_cocos2dx_Node_removeAllComponents);
tolua_function(tolua_S,"_setLocalZOrder",lua_cocos2dx_Node__setLocalZOrder);
tolua_function(tolua_S,"getTag",lua_cocos2dx_Node_getTag);
tolua_function(tolua_S,"getonEnterTransitionDidFinishCallback",lua_cocos2dx_Node_getonEnterTransitionDidFinishCallback);
tolua_function(tolua_S,"getGLProgram",lua_cocos2dx_Node_getGLProgram);
tolua_function(tolua_S,"getNodeToWorldTransform",lua_cocos2dx_Node_getNodeToWorldTransform);
tolua_function(tolua_S,"getPosition3D",lua_cocos2dx_Node_getPosition3D);
@ -9626,8 +10005,10 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
tolua_function(tolua_S,"getEventDispatcher",lua_cocos2dx_Node_getEventDispatcher);
tolua_function(tolua_S,"setSkewX",lua_cocos2dx_Node_setSkewX);
tolua_function(tolua_S,"setGLProgramState",lua_cocos2dx_Node_setGLProgramState);
tolua_function(tolua_S,"setOnEnterCallback",lua_cocos2dx_Node_setOnEnterCallback);
tolua_function(tolua_S,"getOpacity",lua_cocos2dx_Node_getOpacity);
tolua_function(tolua_S,"setNormalizedPosition",lua_cocos2dx_Node_setNormalizedPosition);
tolua_function(tolua_S,"setonExitTransitionDidStartCallback",lua_cocos2dx_Node_setonExitTransitionDidStartCallback);
tolua_function(tolua_S,"convertTouchToNodeSpace",lua_cocos2dx_Node_convertTouchToNodeSpace);
tolua_function(tolua_S,"removeAllChildren",lua_cocos2dx_Node_removeAllChildrenWithCleanup);
tolua_function(tolua_S,"getNodeToParentAffineTransform",lua_cocos2dx_Node_getNodeToParentAffineTransform);
@ -9637,6 +10018,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
tolua_function(tolua_S,"getRotation3D",lua_cocos2dx_Node_getRotation3D);
tolua_function(tolua_S,"getNodeToParentTransform",lua_cocos2dx_Node_getNodeToParentTransform);
tolua_function(tolua_S,"convertTouchToNodeSpaceAR",lua_cocos2dx_Node_convertTouchToNodeSpaceAR);
tolua_function(tolua_S,"getOnEnterCallback",lua_cocos2dx_Node_getOnEnterCallback);
tolua_function(tolua_S,"convertToNodeSpace",lua_cocos2dx_Node_convertToNodeSpace);
tolua_function(tolua_S,"resume",lua_cocos2dx_Node_resume);
tolua_function(tolua_S,"getPhysicsBody",lua_cocos2dx_Node_getPhysicsBody);
@ -9692,6 +10074,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
tolua_function(tolua_S,"getParentToNodeTransform",lua_cocos2dx_Node_getParentToNodeTransform);
tolua_function(tolua_S,"setGlobalZOrder",lua_cocos2dx_Node_setGlobalZOrder);
tolua_function(tolua_S,"setScale",lua_cocos2dx_Node_setScale);
tolua_function(tolua_S,"getOnExitCallback",lua_cocos2dx_Node_getOnExitCallback);
tolua_function(tolua_S,"getChildByTag",lua_cocos2dx_Node_getChildByTag);
tolua_function(tolua_S,"setOrderOfArrival",lua_cocos2dx_Node_setOrderOfArrival);
tolua_function(tolua_S,"getScaleZ",lua_cocos2dx_Node_getScaleZ);
@ -9711,6 +10094,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
tolua_function(tolua_S,"draw",lua_cocos2dx_Node_draw);
tolua_function(tolua_S,"setUserObject",lua_cocos2dx_Node_setUserObject);
tolua_function(tolua_S,"enumerateChildren",lua_cocos2dx_Node_enumerateChildren);
tolua_function(tolua_S,"getonExitTransitionDidStartCallback",lua_cocos2dx_Node_getonExitTransitionDidStartCallback);
tolua_function(tolua_S,"removeFromParent",lua_cocos2dx_Node_removeFromParentAndCleanup);
tolua_function(tolua_S,"setPosition3D",lua_cocos2dx_Node_setPosition3D);
tolua_function(tolua_S,"update",lua_cocos2dx_Node_update);
@ -64880,8 +65264,8 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S)
tolua_module(tolua_S,"cc",0);
tolua_beginmodule(tolua_S,"cc");
lua_register_cocos2dx_Console(tolua_S);
lua_register_cocos2dx_Ref(tolua_S);
lua_register_cocos2dx_Console(tolua_S);
lua_register_cocos2dx_Node(tolua_S);
lua_register_cocos2dx_Scene(tolua_S);
lua_register_cocos2dx_TransitionScene(tolua_S);

View File

@ -1560,6 +1560,14 @@ int register_all_cocos2dx(lua_State* tolua_S);

View File

@ -584,6 +584,8 @@ bool TextField::onTouchBegan(Touch *touch, Event *unusedEvent)
if (_hitted)
{
_textFieldRenderer->attachWithIME();
} else {
this->didNotSelectSelf();
}
return pass;
}

View File

@ -1,8 +1,8 @@
# cocos2d-x v3.2-alpha0 Release Notes #
# cocos2d-x v3.2rc0 Release Notes #
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
- [cocos2d-x v3.2-alpha0 Release Notes](#user-content-cocos2d-x-v32-alpha0-release-notes)
- [cocos2d-x v3.2rc0 Release Notes](#user-content-cocos2d-x-v32rc0-release-notes)
- [Misc Information](#user-content-misc-information)
- [Requirements](#user-content-requirements)
- [Runtime Requirements](#user-content-runtime-requirements)
@ -13,18 +13,21 @@
- [Windows](#user-content-windows)
- [Linux](#user-content-linux)
- [How to start a new game](#user-content-how-to-start-a-new-game)
- [Highlights of v3.2 alpha0](#user-content-highlights-of-v32-alpha0)
- [Highlights of v3.2rc0](#user-content-highlights-of-v32rc0)
- [Toolchain requirement changed](#user-content-toolchain-requirement-changed)
- [Features in detail](#user-content-features-in-detail)
- [Animation3D](#user-content-animation3d)
- [Sprite3d](#user-content-sprite3d)
- [fbx-conv usage](#user-content-fbx-conv-usage)
- [Sample code](#user-content-sample-code)
- [captureScreen](#user-content-capturescreen)
- [Controller support](#user-content-controller-support)
- [Fast tilemap](#user-content-fast-tilemap)
- [Node::enumerateChildren](#user-content-nodeenumeratechildren)
- [utils::findChildren](#user-content-utilsfindchildren)
# Misc Information
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2alpha0.zip
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2alpha0/CHANGELOG
* ~~API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.0/index.html~~
* Download: http://cdn.cocos2d-x.org/cocos2d-x-3.2rc0.zip
* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.2rc0/CHANGELOG
* API Reference: http://www.cocos2d-x.org/reference/native-cpp/V3.2rc0/index.html
* 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
@ -36,14 +39,14 @@
* OS X 10.7 or newer
* Windows 7 or newer
* Windows Phone 8 or newer
* Linux Ubuntu 12.04 or newer
* Linux Ubuntu 14.04 or newer
* ~~Browsers via Emscripten~~ N/A for the moment
## Compiler Requirements
* Xcode 4.6 or newer for iOS or Mac
* gcc 4.7 or newer for Linux
* gcc 4.7 and ndk-r9 or newer for Android
* gcc 4.9 or newer for Linux
* ndk-r9d or newer for Android
* Visual Studio 2012 or newer for Windows (win32)
* Visual Studio 2012 or newer for Windows Phone 8
@ -111,66 +114,104 @@ Run
Please refer to this document: [ReadMe](../README.md)
# Highlights of v3.2 alpha0
# Highlights of v3.2rc0
* `Animation3D`/`Animate3d`, new nodes for 3d animation. lua-binding and WP8 is not supported now.
* Updated libcurl.a to use OpenSSL v1.0.1h, [news](http://cocos2d-x.org/news/286) for it
* Added `utils::captureScreen` to take screeshot
* `fbx-conv` support generating binary format, and `Sprite3D` support it
* about 20% performance improved in `Sprite3D`
* game controller support
* fast tilemap support, it is faster for static tilemap
* physics body supports scale and rotation
* added Node::enumearteChildren(), and support c++ 11 regular expression
# Toolchain requirement changed
`Node::enumerateChildren()` uses `std::regex` which will cause crash using gcc v4.8 or lower version. So
* NDK r9d or newer version is required for Android building
* gcc 4.9 is required for linux building
# Features in detail
## Animation3D
## Sprite3d
Animation3D is skeletal animation in 3D Game. It allows the artist animate a 3D model using bone in 3D modeling tools. Then export the model file and use it in the game.
Sample code to use binary version
```c++
auto sprite3d = Sprite3D::create("filename.c3b");
addChild(sprite3d);
```
Work flow
* Artist produce 3D models in modeling tools and then export it to FBX file
* Use `fbx-conv` convert FBX file to c3t file
* Load c3t file in the game
Note
* The API may change in final version
* binary format of c3t will be added in final version
* the bones in the FBX file should not be more than 50.
### `fbx-conv` usage
* windows
* Mac OS X
```
cd COCOS2DX_ROOT/tools/fbx-convert/win32
fbx-conv FBXFile
```
* mac os x
```
cd COCOS2DX_ROOT/tools/fbx-convert/mac
./fbx-conv FBXFile
$ cd COCOS2DX_ROOT/tools/fbx-conv/mac
$ ./fbx-conv [-a|-b|-t] FBXFile
```
* Windows
### Sample code
```
cd COCOS2DX_ROOT/tools/fbx-conv/windows
fbx-conv [-a|-b|-t] FBXFile
```
Options:
* -a: export both text and binary format
* -b: export binary format
* -t: export text format
## Controller support
Supported controller type:
* amazon tv
* OUYA
* Moga
* Nibiru
* iOS standard controllers
In order to use controller on Android, you should refer to this Android project(`COCOS2DX_ROOT/cocos/platform/android/ControllerManualAdapter`).
Full demo please refer to `COCOS2DX_ROOT/tests/game-controler-test`.
## Fast tilemap
Fast tilemap has the same API as `TMXTiledMap` without deprecated functions.
Sample code
```c++
auto tilemap = FastTMXTiledMap::create("MyFile.tmx");
addChild(tilemap);
```
Full demo please refer to `COCOS2DX_ROOT/tests/cpp-tests/Classes/TileMapTest/TileMapTest2.cpp`.
## Node::enumerateChildren
This functions is used to enumerate children of a `Node` recursively. It supports c++ 11 regular expression.
```c++
//load Sprite3D
auto sprite = Sprite3D::create("girl.c3t");
addChild(sprite);
sprite->setPosition(Vec2( 0, 0));
//load animation and play it
auto animation = Animation3D::getOrCreate("girl.c3t");
if (animation)
{
auto animate = Animate3D::create(animation);
sprite->runAction(RepeatForever::create(animate));
}
// Find nodes whose name is 'nameToFind' and end with digits.
node->enumerateChildren("nameToFind[[:digit:]]+", [](Node* node) -> bool {
...
return false; // return true to stop at first match
});
```
Full sample please refer to [Sprite3D test](https://github.com/cocos2d/cocos2d-x/blob/v3/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp).
Full test please refer to `NodeNameTest` in `COCOS2DX_ROOT/tests/cpp-tests/NodeTest/NodeTest.cpp`.
## captureScreen
Because this function uses `std::regex` which is not supported well in gcc 4.8 or lower version. So we use `clang` and `stdc++` instead for Android building. This lead to the result that `NDK r9d` or newer is required. And `gcc 4.9` is required on linux.
Please refer to [here](https://github.com/cocos2d/cocos2d-x/blob/v3/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp) for usage.
## utils::findChildren
This is a helper function to find children of a `Node` share a name. The implementation of this function bases on `Node::enumerateChildren`.
```c++
auto children = utils::findChildren(node, "nameToFind");
...
```

View File

@ -44,6 +44,18 @@
"files":[
"proj.android/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellocpp",
"files": [
"proj.ios_mac/mac/Info.plist"
]
},
"project_replace_ios_bundleid": {
"src_bundle_id": "org.cocos2dx.hellocpp",
"files": [
"proj.ios_mac/ios/Info.plist"
]
}
}
}

View File

@ -42,7 +42,7 @@
<string>Icon-144.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos2dx.hellocpp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos2dx.hellocpp</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -56,6 +56,18 @@
"files":[
"frameworks/runtime-src/proj.android/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellolua",
"files": [
"frameworks/runtime-src/proj.ios_mac/mac/Info.plist"
]
},
"project_replace_ios_bundleid": {
"src_bundle_id": "org.cocos2dx.hellolua",
"files": [
"frameworks/runtime-src/proj.ios_mac/ios/Info.plist"
]
}
}
}

View File

@ -38,7 +38,7 @@
<string>Icon-144.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos2dx.hellolua</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos2dx.hellolua</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -156,6 +156,18 @@
"files": [
"frameworks/runtime-src/proj.android/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellolua",
"files": [
"frameworks/runtime-src/proj.ios_mac/mac/Info.plist"
]
},
"project_replace_ios_bundleid": {
"src_bundle_id": "org.cocos2dx.hellolua",
"files": [
"frameworks/runtime-src/proj.ios_mac/ios/Info.plist"
]
}
}
}

View File

@ -38,7 +38,7 @@
<string>Icon-144.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos2dx.hellolua</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>org.cocos2d-x.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos2dx.hellolua</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -183,7 +183,7 @@ g_guisTests[] =
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
sceneManager->setCurrentUISceneId(kUIPageViewTest);
sceneManager->setMinUISceneId(kUIPageViewTest);
sceneManager->setMaxUISceneId(kUIPageViewTest);
sceneManager->setMaxUISceneId(kUIPageViewButtonTest);
Scene* scene = sceneManager->currentUIScene();
Director::getInstance()->replaceScene(scene);
}

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIButton_Editor/UIButton_Editor_1.json"));
_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));
this->configureGUIScene();
_sceneTitle = static_cast<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));
_displayValueLabel = Text::create();
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
_displayValueLabel = ui::Text::create();
_displayValueLabel->setFontName("Marker Felt");
_displayValueLabel->setFontSize(30);
_displayValueLabel->setString("No event");
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
_touchGroup->addChild(_displayValueLabel);
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
_touchGroup->addChild(_displayValueLabel,20);
return true;
}

View File

@ -35,7 +35,9 @@ public:
bool init();
void touchEvent(Ref* pSender, Widget::TouchEventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIButtonTest_Editor);
Text* _displayValueLabel;

View File

@ -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()
{
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_2.json"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UICheckBox_Editor/ui_checkbox_editor_1.json"));
_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"));
CheckBox* checkbox = static_cast<CheckBox*>(Helper::seekWidgetByName(root, "CheckBox_540"));
checkbox->addEventListener(CC_CALLBACK_2(UICheckBoxTest_Editor::selectedStateEvent, this));
this->configureGUIScene();
_displayValueLabel = Text::create();
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
@ -44,7 +71,7 @@ bool UICheckBoxTest_Editor::init()
_displayValueLabel->setString("No event");
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
_touchGroup->addChild(_displayValueLabel);
_touchGroup->addChild(_displayValueLabel,20);
return true;
}

View File

@ -34,7 +34,8 @@ public:
~UICheckBoxTest_Editor();
bool init();
void selectedStateEvent(Ref* pSender, CheckBox::EventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UICheckBoxTest_Editor)
Text* _displayValueLabel;

View File

@ -4,26 +4,53 @@
// 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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIImageView_Editor/ui_ImageView_editor_1.json"));
_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;
}

View File

@ -31,7 +31,9 @@ class UIImageViewTest_Editor : public UIScene_Editor
{
public:
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIImageViewTest_Editor)
};

View File

@ -13,44 +13,72 @@ 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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Editor/ui_layout_editor_1.json"));
_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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Color_Editor/ui_layout_color_editor_1.json"));
_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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Gradient_Color_Editor/ui_layout_gradient_color_editor_1_0.csb"));
_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);
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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_BackgroundImage_Editor/ui_layout_backgroundimage_editor_1_0_0.csb"));
_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);
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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Scale9_BackgroundImage_Editor/ui_layout_scale9_backgroundimage_editor.csb"));
_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);
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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Vertical_Layout_Editor/ui_layout_linear_vertical_layout_editor.csb"));
_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);
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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Linear_Horizontal_Layout_Editor/ui_layout_linear_horizontal_layout_editor.csb"));
_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);
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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Parent_Editor/ui_layout_relative_align_parent_editor.csb"));
_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);
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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILayout_Editor/UILayout_Relative_Align_Location_Editor/ui_layout_relative_align_location_editor.csb"));
_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);
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;
}

View File

@ -33,7 +33,8 @@ public:
UILayoutTest_Editor();
~UILayoutTest_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Editor)
};
@ -45,7 +46,8 @@ public:
UILayoutTest_Color_Editor();
~UILayoutTest_Color_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Color_Editor)
};
@ -57,7 +59,8 @@ public:
UILayoutTest_Gradient_Editor();
~UILayoutTest_Gradient_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Gradient_Editor)
};
@ -69,7 +72,8 @@ public:
UILayoutTest_BackGroundImage_Editor();
~UILayoutTest_BackGroundImage_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_BackGroundImage_Editor)
};
@ -81,7 +85,8 @@ public:
UILayoutTest_BackGroundImage_Scale9_Editor();
~UILayoutTest_BackGroundImage_Scale9_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_BackGroundImage_Scale9_Editor)
};
@ -92,6 +97,8 @@ class UILayoutTest_Layout_Linear_Vertical_Editor : public UIScene_Editor
public:
UILayoutTest_Layout_Linear_Vertical_Editor();
~UILayoutTest_Layout_Linear_Vertical_Editor();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
bool init();
protected:
@ -105,7 +112,8 @@ public:
UILayoutTest_Layout_Linear_Horizontal_Editor();
~UILayoutTest_Layout_Linear_Horizontal_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
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();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
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();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILayoutTest_Layout_Relative_Location_Editor)
};

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Vertical_Editor/ui_listview_editor_1.json"));
_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"));
// 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);
this->configureGUIScene();
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()
{
@ -81,38 +162,10 @@ bool UIListViewTest_Horizontal_Editor::init()
{
if (UIScene_Editor::init())
{
// _layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.json"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromBinaryFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIListView_Editor/UIListView_Horizontal_Editor/ui_listview_horizontal_editor_1.json"));
_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;
}

View File

@ -34,7 +34,8 @@ public:
~UIListViewTest_Vertical_Editor();
bool init();
void selectedItemEvent(Ref* pSender, ListView::EventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIListViewTest_Vertical_Editor)
Text* _displayValueLabel;
@ -50,7 +51,8 @@ public:
~UIListViewTest_Horizontal_Editor();
bool init();
void selectedItemEvent(Ref* pSender, ListView::EventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIListViewTest_Horizontal_Editor)
Text* _displayValueLabel;

View File

@ -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()
{
if (UIScene_Editor::init())
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILoadingBar_Editor/ui_loadingbar_editor_1.json"));
_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;
}

View File

@ -13,7 +13,8 @@ public:
bool init();
void update(float delta);
void toCocosGUITestScene(Ref* sender, Widget::TouchEventType event);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILoadingBarTest_Editor)
int _count;

View File

@ -97,3 +97,114 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type)
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;
}
}

View File

@ -41,4 +41,18 @@ protected:
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__) */

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIPageView_Editor/ui_pageview_editor_1.json"));
_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;
}

View File

@ -35,7 +35,8 @@ public:
bool init();
void pageViewEvent(Ref* pSender, PageView::EventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIPageViewTest_Editor)
Text* _displayValueLabel;

View File

@ -100,7 +100,8 @@ static const char* s_testArray[] =
"UIScrollViewTest_Both",
"UIScrollViewTest_ScrollToPercentBothDirection",
"UIScrollViewTest_ScrollToPercentBothDirection_Bounce",
"UIPageViewTest,",
"UIPageViewTest",
"UIPageViewButtonTest",
"UIListViewTest_Vertical",
"UIListViewTest_Horizontal",
/*
@ -344,7 +345,8 @@ Scene *UISceneManager::currentUIScene()
case kUIPageViewTest:
return UIPageViewTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIPageViewButtonTest:
return UIPageViewButtonTest::sceneWithTitle(s_testArray[_currentUISceneId]);
case kUIListViewTest_Vertical:
return UIListViewTest_Vertical::sceneWithTitle(s_testArray[_currentUISceneId]);

View File

@ -90,6 +90,7 @@ enum
kUIScrollViewTest_ScrollToPercentBothDirection,
kUIScrollViewTest_ScrollToPercentBothDirection_Bounce,
kUIPageViewTest,
kUIPageViewButtonTest,
kUIListViewTest_Vertical,
kUIListViewTest_Horizontal,
/*

View File

@ -26,12 +26,37 @@ bool UIScene_Editor::init()
_touchGroup = Layer::create();
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 false;
}
void UIScene_Editor::switchLoadMethod(cocos2d::Ref *pSender)
{
//subclass should override this method
}
void UIScene_Editor::previousCallback(Ref* sender, Widget::TouchEventType event)
{
switch (event)

View File

@ -69,7 +69,8 @@ public:
CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle)
UI_SCENE_EDITOR_CREATE_FUNC(UIScene_Editor);
virtual void switchLoadMethod(Ref* pSender);
protected:
Layer* _touchGroup;
Layout* _layout;

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Vertical_Editor/ui_scrollview_editor_1.json"));
_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;
}
@ -69,45 +96,72 @@ 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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Horizontal_Editor/ui_scrollview_horizontal_editor_1.json"));
_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;
}
@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIScrollView_Editor/UIScrollView_Both_Editor/ui_scrollview_both_editor_1.json"));
_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;
}
@ -183,6 +262,7 @@ UIScrollViewTest_ScrollToPercentBothDirection_Editor::~UIScrollViewTest_ScrollTo
}
bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init()
{
if (UIScene_Editor::init())

View File

@ -33,7 +33,8 @@ public:
UIScrollViewTest_Vertical_Editor();
~UIScrollViewTest_Vertical_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Vertical_Editor)
Text* _displayValueLabel;
@ -46,7 +47,8 @@ public:
UIScrollViewTest_Horizontal_Editor();
~UIScrollViewTest_Horizontal_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Horizontal_Editor)
Text* _displayValueLabel;
@ -59,7 +61,8 @@ public:
UIScrollViewTest_Both_Editor();
~UIScrollViewTest_Both_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_Both_Editor)
Text* _displayValueLabel;
@ -72,7 +75,7 @@ public:
UIScrollViewTest_ScrollToPercentBothDirection_Editor();
~UIScrollViewTest_ScrollToPercentBothDirection_Editor();
bool init();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIScrollViewTest_ScrollToPercentBothDirection_Editor)
Text* _displayValueLabel;

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UISlider_Editor/ui_slider_editor_1.json"));
_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->setFontName("fonts/Marker Felt.ttf");
@ -49,7 +75,7 @@ bool UISliderTest_Editor::init()
_displayValueLabel->setString("No event");
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
_touchGroup->addChild(_displayValueLabel);
_touchGroup->addChild(_displayValueLabel, 20);
return true;
}

View File

@ -12,7 +12,9 @@ public:
~UISliderTest_Editor();
bool init();
void sliderEvent(Ref* pSender, Slider::EventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UISliderTest_Editor)
Text* _displayValueLabel;

View File

@ -3,26 +3,51 @@
#include "UITextAtlasTest_Editor.h"
// 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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelAtlas_Editor/ui_labelatlas_editor_1.json"));
_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;
}

View File

@ -31,7 +31,8 @@ class UITextAtlasTest_Editor : public UIScene_Editor
{
public:
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UITextAtlasTest_Editor)
};

View File

@ -4,26 +4,51 @@
// 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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabelBMFont_Editor/ui_labelbmfont_editor_1.json"));
_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;
}

View File

@ -31,7 +31,8 @@ class UITextBMFontTest_Editor : public UIScene_Editor
{
public:
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UITextBMFontTest_Editor)
};

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UITextField_Editor/ui_textfield_editor_1.json"));
_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"));
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));
this->configureGUIScene();
_displayValueLabel = Text::create();
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
@ -50,7 +77,7 @@ bool UITextFieldTest_Editor::init()
_displayValueLabel->setString("No event");
_displayValueLabel->setPosition(Vec2(_layout->getContentSize().width / 2,
_layout->getContentSize().height - _displayValueLabel->getContentSize().height * 1.75f));
_touchGroup->addChild(_displayValueLabel);
_touchGroup->addChild(_displayValueLabel, 20);
return true;
}

View File

@ -34,7 +34,8 @@ public:
~UITextFieldTest_Editor();
bool init();
void textFieldEvent(Ref* pSender, TextField::EventType type);
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UITextFieldTest_Editor)
Text* _displayValueLabel;

View File

@ -7,25 +7,51 @@
// UITextTest_Editor
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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UILabel_Editor/ui_label_editor_1.json"));
_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;
}

View File

@ -31,7 +31,8 @@ class UITextTest_Editor : public UIScene_Editor
{
public:
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UITextTest_Editor)
};

View File

@ -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()
{
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()->widgetFromBinaryFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.csb"));
_layout = static_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosui/UIEditorTest/UIWidgetAddNode_Editor/ui_widget_add_node_editor.json"));
_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"));
// 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);
this->configureGUIScene();
return true;
}

View File

@ -33,7 +33,8 @@ public:
UIWidgetAddNodeTest_Editor();
~UIWidgetAddNodeTest_Editor();
bool init();
virtual void switchLoadMethod(Ref* pSender);
void configureGUIScene();
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIWidgetAddNodeTest_Editor)
};

View File

@ -32,21 +32,28 @@ void GameControllerTest::onConnectController(Controller* controller, Event* even
{
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)
{
char deviceId[20];
sprintf(deviceId,"device id:%d",controller->getDeviceId());
{
if (_firstHolder._holderNode)
{
_firstHolder.controller = controller;
_firstHolder._deviceIdLabel->setString(deviceId);
_firstHolder._deviceLabel->setString(deviceInfo);
}
else
{
_secondHolder.controller = controller;
_secondHolder._deviceIdLabel->setString(deviceId);
_secondHolder._deviceLabel->setString(deviceInfo);
}
}
else if(_secondHolder.controller == nullptr)
@ -66,9 +73,7 @@ void GameControllerTest::onConnectController(Controller* controller, Event* even
this->addChild(_secondHolder._holderNode);
}
char deviceId[20];
sprintf(deviceId,"device id:%d",controller->getDeviceId());
_secondHolder._deviceIdLabel->setString(deviceId);
_secondHolder._deviceLabel->setString(deviceInfo);
}
else
{
@ -86,9 +91,8 @@ void GameControllerTest::onConnectController(Controller* controller, Event* even
_firstHolder._holderNode->setPosition(Vec2(_visibleThreeQuarterX, _visibleCentreY));
this->addChild(_firstHolder._holderNode);
}
char deviceId[20];
sprintf(deviceId,"device id:%d",controller->getDeviceId());
_firstHolder._deviceIdLabel->setString(deviceId);
_firstHolder._deviceLabel->setString(deviceInfo);
}
}
@ -144,7 +148,7 @@ void GameControllerTest::resetControllerHolderState(ControllerHolder& holder)
holder._leftJoystick->setPosition(Vec2(238,460));
holder._rightJoystick->setPosition(Vec2(606,293));
holder._deviceIdLabel->setString("Disconnected");
holder._deviceLabel->setString("Disconnected");
}
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));
break;
default:
break;
{
char ketStatus[30];
sprintf(ketStatus,"Key Down:%d",keyCode);
holder->_externalKeyLabel->setString(ketStatus);
break;
}
}
}
else
@ -231,7 +240,12 @@ void GameControllerTest::showButtonState(cocos2d::Controller *controller, int ke
holder->_buttonR1->setColor(Color3B::WHITE);
break;
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)
{
//onConnectController(controller,nullptr);
ControllerHolder* holder = nullptr;
if (controller == _firstHolder.controller)
holder = &_firstHolder;
@ -344,12 +357,16 @@ void GameControllerTest::createControllerSprite(ControllerHolder& holder)
holder._rightJoystick->setPosition(Vec2(606,293));
holder._holderNode->addChild(holder._rightJoystick);
holder._deviceIdLabel = Label::createWithTTF("Disconnected","fonts/Marker Felt.ttf",36);
holder._deviceIdLabel->setPosition(Vec2(499,460));
holder._deviceIdLabel->setTextColor(Color4B::RED);
holder._holderNode->addChild(holder._deviceIdLabel);
holder._deviceLabel = Label::createWithTTF("Disconnected","fonts/Marker Felt.ttf",36);
holder._deviceLabel->setPosition(Vec2(499,650));
holder._deviceLabel->setTextColor(Color4B::RED);
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 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._holderNode->addChild(holder._buttonR2);
//-----------------------------------------------------------------
//750 460,70
holder._buttonX = Sprite::create("X.png");
holder._buttonX->setPosition(Vec2(750 - 70,460));
holder._holderNode->addChild(holder._buttonX);

View File

@ -53,7 +53,8 @@ private:
cocos2d::Sprite* _buttonL2;
cocos2d::Sprite* _buttonR2;
cocos2d::Label* _deviceIdLabel;
cocos2d::Label* _deviceLabel;
cocos2d::Label* _externalKeyLabel;
}ControllerHolder;
ControllerHolder _firstHolder;

View File

@ -1,5 +1,6 @@
require "src/ExtensionTest/CocosBuilderTest"
require "src/ExtensionTest/WebProxyTest"
require "src/ExtensionTest/SceneEditorTest"
local LINE_SPACE = 40
local kItemTagBasic = 1000
@ -13,7 +14,8 @@ local ExtensionTestEnum =
TEST_EDITBOX = 4,
TEST_TABLEVIEW = 5,
TEST_SCROLLVIEW = 6,
TEST_MAX_COUNT = 7,
TEST_STUDIOSCENE = 7,
TEST_MAX_COUNT = 8,
}
local testsName =
@ -25,6 +27,7 @@ local testsName =
"EditBoxTest",
"TableViewTest",
"ScrollViewTest",
"CocoStudioSceneTest",
}
@ -1187,6 +1190,7 @@ local CreateExtensionsTestTable =
runEditBoxTest,
runTableViewTest,
runScrollViewTest,
runStudioSceneTest,
}
@ -1267,7 +1271,7 @@ local function ExtensionsMainLayer()
local listener = cc.EventListenerTouchAllAtOnce:create()
listener:registerScriptHandler(onTouchesBegan,cc.Handler.EVENT_TOUCHES_BEGAN )
listener:registerScriptHandler(onTouchesMoved,cc.Handler.EVENT_TOUCH_MOVED )
listener:registerScriptHandler(onTouchesMoved,cc.Handler.EVENT_TOUCHES_MOVED )
local eventDispatcher = layer:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener, layer)

View File

@ -0,0 +1,270 @@
require "CCBReaderLoad"
function SceneEditorTestLayer(filename)
local layer = cc.Layer:create()
local isCsbLoad = false;
local loadtypeStr = {"change to load \nwith binary file","change to load \nwith json file"}
local loadtypelb = cc.Label:createWithSystemFont(loadtypeStr[1], "Arial", 12);
local filePath = filename
layer.rootNode = nil
function layer:defaultPlay()end
local loadFileChangeHelper = function(filename)
if filename ~= nil then
if isCsbLoad then
return filename .. ".csb"
else
return filename .. ".json"
end
end
return filename
end
local changeLoadTypeCallback = function(sender)
isCsbLoad = not isCsbLoad
loadtypelb:setString(loadtypeStr[isCsbLoad == false and 1 or 2])
local file = loadFileChangeHelper(filePath)
if layer.rootNode ~= nil then
layer:removeChild(layer.rootNode)
layer.rootNode = SceneReader:getInstance():createNodeWithSceneFile(file)
layer:addChild(layer.rootNode, 0, 1)
layer:defaultPlay()
end
end
function layer:enter()
layer.rootNode = SceneReader:getInstance():createNodeWithSceneFile(loadFileChangeHelper(filePath))
layer:addChild(layer.rootNode, 0, 1)
layer:defaultPlay()
end
function layer:exit()
ccs.ArmatureDataManager:destroyInstance()
ccs.SceneReader:destroyInstance()
ccs.ActionManagerEx:destroyInstance()
ccs.GUIReader:destroyInstance()
end
local function onNodeEvent(event)
if "enter" == event then
layer:enter()
elseif "exit" == event then
layer:exit()
end
end
layer:registerScriptHandler(onNodeEvent)
local itemlb = cc.MenuItemLabel:create(loadtypelb)
itemlb:registerScriptTapHandler(changeLoadTypeCallback)
local loadtypemenu = cc.Menu:create(itemlb)
loadtypemenu:setPosition(cc.p(VisibleRect:rightTop().x -50,VisibleRect:rightTop().y -20));
layer:addChild(loadtypemenu,100);
Helper.initWithLayer(layer)
Helper.titleLabel:setString("SceneReader Test LoadSceneEditorFile")
return layer
end
function LoadSceneEdtiorFileTest()
local layer = SceneEditorTestLayer("scenetest/LoadSceneEdtiorFileTest/FishJoy2")
Helper.titleLabel:setString("loadSceneEdtiorFile Test")
return layer
end
function SpriteComponentTest()
local layer = SceneEditorTestLayer("scenetest/SpriteComponentTest/SpriteComponentTest")
Helper.titleLabel:setString("Sprite Component Test")
function layer:defaultPlay()
layer.rootNode:getChildByTag(10003):getComponent("CCSprite"):getNode():runAction(cc.Blink:create(2, 10));
layer.rootNode:getChildByTag(10004):getComponent("CCSprite"):getNode():runAction(cc.Blink:create(2, 5));
end
return layer
end
function ArmatureComponentTest()
local layer = SceneEditorTestLayer("scenetest/ArmatureComponentTest/ArmatureComponentTest")
Helper.titleLabel:setString("Armature Component Test")
function layer:defaultPlay()
layer.rootNode:getChildByTag(10007):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
layer.rootNode:getChildByTag(10008):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
end
return layer
end
function UIComponentTest()
local layer = SceneEditorTestLayer("scenetest/UIComponentTest/UIComponentTest")
Helper.titleLabel:setString("UI Component Test")
local function touchEvent(sender,eventType)
if eventType == ccui.TouchEventType.began then
layer.rootNode:getChildByTag(10010):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
layer.rootNode:getChildByTag(10011):getComponent("CCArmature"):getNode():runAction(cc.MoveBy:create(10.0, cc.p(-1000.0, 0)))
end
end
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10025):getComponent("GUIComponent")
local widget = render:getNode()
local button = widget:getChildByName("Button_156")
button:addTouchEventListener(touchEvent)
end
return layer
end
function TmxMapComponentTest()
local layer = SceneEditorTestLayer("scenetest/TmxMapComponentTest/TmxMapComponentTest")
Helper.titleLabel:setString("TmxMap Component Test")
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10015):getComponent("CCTMXTiledMap")
local skewTo = cc.SkewTo:create(2, 0, 2);
local rotateTo = cc.RotateTo:create(2, 61);
local scaleTo = cc.ScaleTo:create(2, -0.44, 0.47);
local scaleBack = cc.ScaleTo:create(2, 1, 1);
local rotateBack = cc.RotateTo:create(2, 0);
local skewBack = cc.SkewTo:create(2, 0, 0);
render:getNode():runAction(cc.Sequence:create(skewTo, skewBack));
render:getNode():runAction(cc.Sequence:create(rotateTo, rotateBack));
render:getNode():runAction(cc.Sequence:create(scaleTo, scaleBack));
end
return layer
end
function ParticleComponentTest()
local layer = SceneEditorTestLayer("scenetest/ParticleComponentTest/ParticleComponentTest")
Helper.titleLabel:setString("Particle Component Test")
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10020):getComponent("CCParticleSystemQuad")
local action = cc.JumpBy:create(5, cc.p(-500,0), 50, 4);
render:getNode():runAction(cc.Sequence:create(action, action:reverse()))
end
return layer
end
function EffectComponentTest()
local layer = SceneEditorTestLayer("scenetest/EffectComponentTest/EffectComponentTest")
Helper.titleLabel:setString("Effect Component Test")
local animationEvent = function(armature,movementType,movementID)
if movementType == ccs.MovementEventType.loopComplete then
if movementID == "Fire" then
layer.rootNode:getChildByTag(10015):getComponent("CCComAudio"):playEffect()
end
end
end
function layer:defaultPlay()
local render = layer.rootNode:getChildByTag(10015):getComponent("CCArmature")
render:getNode():getAnimation():setMovementEventCallFunc(animationEvent);
end
return layer
end
function BackgroundComponentTest()
local layer = SceneEditorTestLayer("scenetest/BackgroundComponentTest/BackgroundComponentTest")
Helper.titleLabel:setString("Background Component Test")
function layer:defaultPlay()
layer.rootNode:getComponent("CCBackgroundAudio"):playBackgroundMusic();
end
return layer
end
function AttributeComponentTest()
local layer = SceneEditorTestLayer("scenetest/AttributeComponentTest/AttributeComponentTest")
Helper.titleLabel:setString("Attribute Component Test")
function layer:defaultPlay()
local attribute = layer.rootNode:getChildByTag(10015):getComponent("CCComAttribute")
cclog("Name: " .. attribute:getString("name") .. ", HP: " .. attribute:getFloat("maxHP") .. ", MP: " .. attribute:getFloat("maxMP"))
end
return layer
end
function TriggerTest()
local layer = SceneEditorTestLayer("scenetest/TriggerTest/TriggerTest")
Helper.titleLabel:setString("Trigger Test")
local function onTouchBegan(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHBEGAN)
end
local function onTouchMoved(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHMOVED)
end
local function onTouchEnded(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHENDED)
end
local function onTouchCancelled(touch, event)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_TOUCHCANCELLED)
end
local touchListener = cc.EventListenerTouchOneByOne:create()
touchListener:setSwallowTouches(true)
touchListener:registerScriptHandler(onTouchBegan, cc.Handler.EVENT_TOUCH_BEGAN)
touchListener:registerScriptHandler(onTouchMoved, cc.Handler.EVENT_TOUCH_MOVED)
touchListener:registerScriptHandler(onTouchEnded, cc.Handler.EVENT_TOUCH_ENDED)
touchListener:registerScriptHandler(onTouchCancelled, cc.Handler.EVENT_TOUCH_CANCELLED)
local eventDispatcher = layer:getEventDispatcher()
eventDispatcher:addEventListenerWithFixedPriority(touchListener, 1)
local function gameLogic(dt)
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_UPDATESCENE)
end
local layerExit = layer.exit
function layer:exit()
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_LEAVESCENE)
layer:unschedule(gameLogic)
eventDispatcher:removeEventListener(touchListener)
layerExit(layer)
end
schedule(layer,gameLogic)
function layer:defaultPlay()
ccs.sendTriggerEvent(triggerEventDef.TRIGGEREVENT_ENTERSCENE);
end
return layer
end
function runStudioSceneTest()
local scene = cc.Scene:create()
Helper.createFunctionTable = {
LoadSceneEdtiorFileTest,
SpriteComponentTest,
ArmatureComponentTest,
UIComponentTest,
TmxMapComponentTest,
ParticleComponentTest,
EffectComponentTest,
BackgroundComponentTest,
AttributeComponentTest,
TriggerTest,
}
scene:addChild(Helper.createFunctionTable[1]())
scene:addChild(CreateBackMenuItem())
return scene
end

@ -1 +1 @@
Subproject commit f0ff6e6eb0c28a1733f086e554bb4fadb91e1cfc
Subproject commit 7fc616bcbcfd9b60e8b1188ba974e4f66621beb8