mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into opengl_develop
This commit is contained in:
commit
08b951fa12
|
@ -25,6 +25,9 @@ script:
|
||||||
- export NACL_SDK_ROOT=$HOME/bin/nacl_sdk/pepper_canary
|
- export NACL_SDK_ROOT=$HOME/bin/nacl_sdk/pepper_canary
|
||||||
- export PATH=$PATH:$NACL_SDK_ROOT/toolchain/linux_x86_newlib/bin
|
- export PATH=$PATH:$NACL_SDK_ROOT/toolchain/linux_x86_newlib/bin
|
||||||
- export NDK_ROOT=$HOME/bin/android-ndk
|
- export NDK_ROOT=$HOME/bin/android-ndk
|
||||||
|
- export PYTHON=/usr/bin/python
|
||||||
|
- export LLVM=$HOME/bin/clang+llvm-3.2/bin
|
||||||
|
- export LLVM_ROOT=$LLVM
|
||||||
- ./tools/travis-scripts/run-script.sh
|
- ./tools/travis-scripts/run-script.sh
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
|
|
1
AUTHORS
1
AUTHORS
|
@ -474,6 +474,7 @@ Developers:
|
||||||
edwardzhou (Edward Zhou)
|
edwardzhou (Edward Zhou)
|
||||||
Correcting the type detecting order for Lua CCBProxy::getNodeTypeName.
|
Correcting the type detecting order for Lua CCBProxy::getNodeTypeName.
|
||||||
Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash.
|
Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash.
|
||||||
|
fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern.
|
||||||
|
|
||||||
musikov
|
musikov
|
||||||
Fixing a bug that missing precision when getting strokeColor and fontFillColor
|
Fixing a bug that missing precision when getting strokeColor and fontFillColor
|
||||||
|
|
|
@ -235,11 +235,11 @@ void CCLayer::setAccelerometerEnabled(bool enabled)
|
||||||
CCDirector* pDirector = CCDirector::sharedDirector();
|
CCDirector* pDirector = CCDirector::sharedDirector();
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
pDirector->getAccelerometer()->setDelegate(this);
|
pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(CCLayer::didAccelerate, this));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pDirector->getAccelerometer()->setDelegate(NULL);
|
pDirector->getAccelerometer()->setDelegate(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ void CCLayer::onEnter()
|
||||||
// add this layer to concern the Accelerometer Sensor
|
// add this layer to concern the Accelerometer Sensor
|
||||||
if (_accelerometerEnabled)
|
if (_accelerometerEnabled)
|
||||||
{
|
{
|
||||||
pDirector->getAccelerometer()->setDelegate(this);
|
pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(CCLayer::didAccelerate, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add this layer to concern the keypad msg
|
// add this layer to concern the keypad msg
|
||||||
|
@ -419,7 +419,7 @@ void CCLayer::onEnterTransitionDidFinish()
|
||||||
if (_accelerometerEnabled)
|
if (_accelerometerEnabled)
|
||||||
{
|
{
|
||||||
CCDirector* pDirector = CCDirector::sharedDirector();
|
CCDirector* pDirector = CCDirector::sharedDirector();
|
||||||
pDirector->getAccelerometer()->setDelegate(this);
|
pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(CCLayer::didAccelerate, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
CCNode::onEnterTransitionDidFinish();
|
CCNode::onEnterTransitionDidFinish();
|
||||||
|
|
|
@ -60,7 +60,7 @@ All features from CCNode are valid, plus the following new features:
|
||||||
- It can receive iPhone Touches
|
- It can receive iPhone Touches
|
||||||
- It can receive Accelerometer input
|
- It can receive Accelerometer input
|
||||||
*/
|
*/
|
||||||
class CC_DLL CCLayer : public CCNode, public CCTouchDelegate, public CCAccelerometerDelegate, public CCKeypadDelegate
|
class CC_DLL CCLayer : public CCNode, public CCTouchDelegate, public CCKeypadDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCLayer();
|
CCLayer();
|
||||||
|
|
|
@ -43,17 +43,6 @@ public:
|
||||||
CCAcceleration(): x(0), y(0), z(0), timestamp(0) {}
|
CCAcceleration(): x(0), y(0), z(0), timestamp(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
@brief
|
|
||||||
The CCAccelerometerDelegate defines a single method for
|
|
||||||
receiving acceleration-related data from the system.
|
|
||||||
*/
|
|
||||||
class CC_DLL CCAccelerometerDelegate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void didAccelerate(CCAcceleration* pAccelerationValue) {CC_UNUSED_PARAM(pAccelerationValue);}
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,7 +32,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
namespace cocos2d
|
namespace cocos2d
|
||||||
{
|
{
|
||||||
CCAccelerometer::CCAccelerometer() : _accelDelegate(NULL)
|
CCAccelerometer::CCAccelerometer() : _function(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ namespace cocos2d
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
void CCAccelerometer::setDelegate(std::function<void(CCAcceleration*)> function)
|
||||||
{
|
{
|
||||||
_accelDelegate = pDelegate;
|
_function = function;
|
||||||
|
|
||||||
if (pDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
enableAccelerometerJNI();
|
enableAccelerometerJNI();
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ namespace cocos2d
|
||||||
|
|
||||||
void CCAccelerometer::update(float x, float y, float z, long sensorTimeStamp)
|
void CCAccelerometer::update(float x, float y, float z, long sensorTimeStamp)
|
||||||
{
|
{
|
||||||
if (_accelDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
_accelerationValue.x = -((double)x / TG3_GRAVITY_EARTH);
|
_accelerationValue.x = -((double)x / TG3_GRAVITY_EARTH);
|
||||||
_accelerationValue.y = -((double)y / TG3_GRAVITY_EARTH);
|
_accelerationValue.y = -((double)y / TG3_GRAVITY_EARTH);
|
||||||
_accelerationValue.z = -((double)z / TG3_GRAVITY_EARTH);
|
_accelerationValue.z = -((double)z / TG3_GRAVITY_EARTH);
|
||||||
_accelerationValue.timestamp = (double)sensorTimeStamp;
|
_accelerationValue.timestamp = (double)sensorTimeStamp;
|
||||||
|
|
||||||
_accelDelegate->didAccelerate(&_accelerationValue);
|
_function(&_accelerationValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // end of namespace cococs2d
|
} // end of namespace cococs2d
|
||||||
|
|
|
@ -27,21 +27,22 @@ THE SOFTWARE.
|
||||||
|
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
class CC_DLL CCAccelerometer
|
class CCAccelerometer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCAccelerometer();
|
CCAccelerometer();
|
||||||
~CCAccelerometer();
|
~CCAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(std::function<void(CCAcceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval);
|
void setAccelerometerInterval(float interval);
|
||||||
void update(float x, float y, float z, long sensorTimeStamp);
|
void update(float x, float y, float z, long sensorTimeStamp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CCAccelerometerDelegate* _accelDelegate;
|
std::function<void(CCAcceleration*)> _function;
|
||||||
CCAcceleration _accelerationValue;
|
CCAcceleration _accelerationValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ int CCAccelerometer::_initialOrientationAngle = 0;
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer()
|
CCAccelerometer::CCAccelerometer()
|
||||||
{
|
{
|
||||||
_accelDelegate = NULL;
|
_function = nullptr;
|
||||||
_initialOrientationAngle = atoi(getenv("ORIENTATION"));
|
_initialOrientationAngle = atoi(getenv("ORIENTATION"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ CCAccelerometer::~CCAccelerometer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
void CCAccelerometer::setDelegate(std::function<void(CCAcceleration*)> function)
|
||||||
{
|
{
|
||||||
_accelDelegate = pDelegate;
|
_function = function;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::update(long timeStamp, double x, double y, double z)
|
void CCAccelerometer::update(long timeStamp, double x, double y, double z)
|
||||||
{
|
{
|
||||||
if ( _accelDelegate != NULL)
|
if ( _function != NULL)
|
||||||
{
|
{
|
||||||
if (getenv("WIDTH"))
|
if (getenv("WIDTH"))
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ void CCAccelerometer::update(long timeStamp, double x, double y, double z)
|
||||||
_accelerationValue.z = z;
|
_accelerationValue.z = z;
|
||||||
_accelerationValue.timestamp = (double)timeStamp;
|
_accelerationValue.timestamp = (double)timeStamp;
|
||||||
|
|
||||||
_accelDelegate->didAccelerate(&_accelerationValue);
|
_function(&_accelerationValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ THE SOFTWARE.
|
||||||
#ifndef __PLATFORM_CCACCELEROMETER_BLACKBERRY_H__
|
#ifndef __PLATFORM_CCACCELEROMETER_BLACKBERRY_H__
|
||||||
#define __PLATFORM_CCACCELEROMETER_BLACKBERRY_H__
|
#define __PLATFORM_CCACCELEROMETER_BLACKBERRY_H__
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
@ -35,12 +36,12 @@ public:
|
||||||
CCAccelerometer();
|
CCAccelerometer();
|
||||||
~CCAccelerometer();
|
~CCAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(std::function<void(CCAcceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||||
void update(long sensorTimeStamp, double x, double y, double z);
|
void update(long sensorTimeStamp, double x, double y, double z);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CCAccelerometerDelegate* _accelDelegate;
|
std::function<void(CCAcceleration*)> _function;
|
||||||
CCAcceleration _accelerationValue;
|
CCAcceleration _accelerationValue;
|
||||||
static int _initialOrientationAngle;
|
static int _initialOrientationAngle;
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define CCACCELEROMETER_H_
|
#define CCACCELEROMETER_H_
|
||||||
|
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
|
@ -20,9 +21,9 @@ public:
|
||||||
|
|
||||||
static CCAccelerometer* sharedAccelerometer() { return NULL; };
|
static CCAccelerometer* sharedAccelerometer() { return NULL; };
|
||||||
|
|
||||||
void removeDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void removeDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void addDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void addDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void setDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
#import "CCAccelerometerDelegate.h"
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
|
|
||||||
@interface AccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
|
|
||||||
{
|
|
||||||
cocos2d::CCAccelerometerDelegate *delegate_;
|
|
||||||
cocos2d::CCAcceleration *acceleration_;
|
|
||||||
}
|
|
||||||
|
|
||||||
@property(readwrite) cocos2d::CCAccelerometerDelegate *delegate_;
|
|
||||||
@property(readwrite) cocos2d::CCAcceleration *acceleration_;
|
|
||||||
|
|
||||||
+ (id) sharedAccelerometerDispather;
|
|
||||||
- (id) init;
|
|
||||||
- (void) addDelegate: (cocos2d::CCAccelerometerDelegate *) delegate;
|
|
||||||
- (void) setAccelerometerInterval:(float)interval;
|
|
||||||
|
|
||||||
@end
|
|
|
@ -1,115 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#import "AccelerometerDelegateWrapper.h"
|
|
||||||
|
|
||||||
@implementation AccelerometerDispatcher
|
|
||||||
|
|
||||||
static AccelerometerDispatcher* s_pAccelerometerDispatcher;
|
|
||||||
|
|
||||||
@synthesize delegate_;
|
|
||||||
@synthesize acceleration_;
|
|
||||||
|
|
||||||
+ (id) sharedAccelerometerDispather
|
|
||||||
{
|
|
||||||
if (s_pAccelerometerDispatcher == nil) {
|
|
||||||
s_pAccelerometerDispatcher = [[self alloc] init];
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_pAccelerometerDispatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
acceleration_ = new cocos2d::CCAcceleration();
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) dealloc
|
|
||||||
{
|
|
||||||
s_pAccelerometerDispatcher = 0;
|
|
||||||
delegate_ = 0;
|
|
||||||
delete acceleration_;
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) addDelegate: (cocos2d::CCAccelerometerDelegate *) delegate
|
|
||||||
{
|
|
||||||
delegate_ = delegate;
|
|
||||||
|
|
||||||
if (delegate_)
|
|
||||||
{
|
|
||||||
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void) setAccelerometerInterval:(float)interval
|
|
||||||
{
|
|
||||||
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:interval];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
|
|
||||||
{
|
|
||||||
if (! delegate_)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
acceleration_->x = acceleration.x;
|
|
||||||
acceleration_->y = acceleration.y;
|
|
||||||
acceleration_->z = acceleration.z;
|
|
||||||
acceleration_->timestamp = acceleration.timestamp;
|
|
||||||
|
|
||||||
double tmp = acceleration_->x;
|
|
||||||
|
|
||||||
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
|
||||||
{
|
|
||||||
case UIInterfaceOrientationLandscapeRight:
|
|
||||||
acceleration_->x = -acceleration_->y;
|
|
||||||
acceleration_->y = tmp;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIInterfaceOrientationLandscapeLeft:
|
|
||||||
acceleration_->x = acceleration_->y;
|
|
||||||
acceleration_->y = -tmp;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIInterfaceOrientationPortraitUpsideDown:
|
|
||||||
acceleration_->x = -acceleration_->y;
|
|
||||||
acceleration_->y = -tmp;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UIInterfaceOrientationPortrait:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate_->didAccelerate(acceleration_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
|
@ -25,17 +25,18 @@ THE SOFTWARE.
|
||||||
#ifndef __PLATFORM_IPHONE_CCACCELEROMETER_H__
|
#ifndef __PLATFORM_IPHONE_CCACCELEROMETER_H__
|
||||||
#define __PLATFORM_IPHONE_CCACCELEROMETER_H__
|
#define __PLATFORM_IPHONE_CCACCELEROMETER_H__
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
class CC_DLL CCAccelerometer
|
class CCAccelerometer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CCAccelerometer();
|
CCAccelerometer();
|
||||||
~CCAccelerometer();
|
~CCAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(std::function<void(CCAcceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval);
|
void setAccelerometerInterval(float interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,21 +23,124 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "CCAccelerometer.h"
|
#include "CCAccelerometer.h"
|
||||||
#include "AccelerometerDelegateWrapper.h"
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "CCAccelerometerDelegate.h"
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <functional>
|
||||||
|
|
||||||
|
@interface AccelerometerDispatcher : NSObject<UIAccelerometerDelegate>
|
||||||
|
{
|
||||||
|
std::function<void(cocos2d::CCAcceleration*)> _function;
|
||||||
|
cocos2d::CCAcceleration *_acceleration;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (id) sharedAccelerometerDispather;
|
||||||
|
- (id) init;
|
||||||
|
- (void) addDelegate: (std::function<void(cocos2d::CCAcceleration*)>) function;
|
||||||
|
- (void) setAccelerometerInterval:(float)interval;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation AccelerometerDispatcher
|
||||||
|
|
||||||
|
static AccelerometerDispatcher* s_pAccelerometerDispatcher;
|
||||||
|
|
||||||
|
+ (id) sharedAccelerometerDispather
|
||||||
|
{
|
||||||
|
if (s_pAccelerometerDispatcher == nil) {
|
||||||
|
s_pAccelerometerDispatcher = [[self alloc] init];
|
||||||
|
}
|
||||||
|
|
||||||
|
return s_pAccelerometerDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
_acceleration = new cocos2d::CCAcceleration();
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
s_pAccelerometerDispatcher = nullptr;
|
||||||
|
_function = nullptr;
|
||||||
|
delete _acceleration;
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) addDelegate: (std::function<void(cocos2d::CCAcceleration*)>) function
|
||||||
|
{
|
||||||
|
_function = function;
|
||||||
|
|
||||||
|
if (_function)
|
||||||
|
{
|
||||||
|
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) setAccelerometerInterval:(float)interval
|
||||||
|
{
|
||||||
|
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:interval];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
|
||||||
|
{
|
||||||
|
if (! _function)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_acceleration->x = acceleration.x;
|
||||||
|
_acceleration->y = acceleration.y;
|
||||||
|
_acceleration->z = acceleration.z;
|
||||||
|
_acceleration->timestamp = acceleration.timestamp;
|
||||||
|
|
||||||
|
double tmp = _acceleration->x;
|
||||||
|
|
||||||
|
switch ([[UIApplication sharedApplication] statusBarOrientation])
|
||||||
|
{
|
||||||
|
case UIInterfaceOrientationLandscapeRight:
|
||||||
|
_acceleration->x = -_acceleration->y;
|
||||||
|
_acceleration->y = tmp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UIInterfaceOrientationLandscapeLeft:
|
||||||
|
_acceleration->x = _acceleration->y;
|
||||||
|
_acceleration->y = -tmp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UIInterfaceOrientationPortraitUpsideDown:
|
||||||
|
_acceleration->x = -_acceleration->y;
|
||||||
|
_acceleration->y = -tmp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UIInterfaceOrientationPortrait:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_function(_acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/** Implementation of CCAccelerometer
|
||||||
|
*/
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CCAccelerometer::~CCAccelerometer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
CCAccelerometer::CCAccelerometer() {}
|
||||||
|
|
||||||
|
CCAccelerometer::~CCAccelerometer() {}
|
||||||
|
|
||||||
|
void CCAccelerometer::setDelegate(std::function<void (CCAcceleration *)> function)
|
||||||
{
|
{
|
||||||
[[AccelerometerDispatcher sharedAccelerometerDispather] addDelegate:pDelegate];
|
[[AccelerometerDispatcher sharedAccelerometerDispather] addDelegate:function];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::setAccelerometerInterval(float interval)
|
void CCAccelerometer::setAccelerometerInterval(float interval)
|
||||||
|
@ -46,4 +149,3 @@ void CCAccelerometer::setAccelerometerInterval(float interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
||||||
|
|
|
@ -123,29 +123,6 @@ static bool _initWithImage(CGImageRef cgImage, tImageInfo *pImageinfo)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _initWithFile(const char* path, tImageInfo *pImageinfo)
|
|
||||||
{
|
|
||||||
CGImageRef CGImage;
|
|
||||||
UIImage *jpg;
|
|
||||||
UIImage *png;
|
|
||||||
bool ret;
|
|
||||||
|
|
||||||
// convert jpg to png before loading the texture
|
|
||||||
|
|
||||||
NSString *fullPath = [NSString stringWithUTF8String:path];
|
|
||||||
jpg = [[UIImage alloc] initWithContentsOfFile: fullPath];
|
|
||||||
png = [[UIImage alloc] initWithData:UIImagePNGRepresentation(jpg)];
|
|
||||||
CGImage = png.CGImage;
|
|
||||||
|
|
||||||
ret = _initWithImage(CGImage, pImageinfo);
|
|
||||||
|
|
||||||
[png release];
|
|
||||||
[jpg release];
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo)
|
static bool _initWithData(void * pBuffer, int length, tImageInfo *pImageinfo)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define CCACCELEROMETER_H_
|
#define CCACCELEROMETER_H_
|
||||||
|
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
|
@ -20,9 +21,9 @@ public:
|
||||||
|
|
||||||
static CCAccelerometer* sharedAccelerometer() { return NULL; };
|
static CCAccelerometer* sharedAccelerometer() { return NULL; };
|
||||||
|
|
||||||
void removeDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void removeDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void addDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void addDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void setDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace cocos2d
|
||||||
|
|
||||||
CCAccelerometer* CCAccelerometer::_spCCAccelerometer = NULL;
|
CCAccelerometer* CCAccelerometer::_spCCAccelerometer = NULL;
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer() : _accelDelegate(NULL)
|
CCAccelerometer::CCAccelerometer() : _function(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,11 +53,11 @@ CCAccelerometer* CCAccelerometer::sharedAccelerometer()
|
||||||
return _spCCAccelerometer;
|
return _spCCAccelerometer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
void CCAccelerometer::setDelegate(std::function<void(CCAcceleration*)> function)
|
||||||
{
|
{
|
||||||
_accelDelegate = pDelegate;
|
_function = function;
|
||||||
|
|
||||||
if (pDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
if (s3eAccelerometerStart() != S3E_RESULT_SUCCESS)
|
if (s3eAccelerometerStart() != S3E_RESULT_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -72,14 +72,14 @@ void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
||||||
|
|
||||||
void CCAccelerometer::update(float x, float y, float z, uint64 sensorTimeStamp)
|
void CCAccelerometer::update(float x, float y, float z, uint64 sensorTimeStamp)
|
||||||
{
|
{
|
||||||
if (_accelDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
_accelerationValue.x = ((double)x)/S3E_ACCELEROMETER_1G ;
|
_accelerationValue.x = ((double)x)/S3E_ACCELEROMETER_1G ;
|
||||||
_accelerationValue.y = ((double)y)/S3E_ACCELEROMETER_1G ;
|
_accelerationValue.y = ((double)y)/S3E_ACCELEROMETER_1G ;
|
||||||
_accelerationValue.z = ((double)z)/S3E_ACCELEROMETER_1G ;
|
_accelerationValue.z = ((double)z)/S3E_ACCELEROMETER_1G ;
|
||||||
_accelerationValue.timestamp = (double)(sensorTimeStamp / 1000.0);
|
_accelerationValue.timestamp = (double)(sensorTimeStamp / 1000.0);
|
||||||
|
|
||||||
_accelDelegate->didAccelerate(&_accelerationValue);
|
_function(&_accelerationValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "CCAccelerometerDelegate.h"
|
#include "CCAccelerometerDelegate.h"
|
||||||
//#include "CCMutableArray.h"
|
//#include "CCMutableArray.h"
|
||||||
#include "ccCommon.h"
|
#include "ccCommon.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ public:
|
||||||
*/
|
*/
|
||||||
static CCAccelerometer* sharedAccelerometer();
|
static CCAccelerometer* sharedAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(std::function<void(CCAcceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||||
void update(float x, float y, float z, uint64 sensorTimeStamp);
|
void update(float x, float y, float z, uint64 sensorTimeStamp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CCAccelerometer* _spCCAccelerometer;
|
static CCAccelerometer* _spCCAccelerometer;
|
||||||
CCAccelerometerDelegate* _accelDelegate;
|
std::function<void(CCAcceleration*)> _function;
|
||||||
CCAcceleration _accelerationValue;
|
CCAcceleration _accelerationValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||||
#define __CCACCELEROMETER_H__
|
#define __CCACCELEROMETER_H__
|
||||||
|
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
|
@ -37,8 +38,8 @@ public:
|
||||||
|
|
||||||
static CCAccelerometer* sharedAccelerometer() { return NULL; };
|
static CCAccelerometer* sharedAccelerometer() { return NULL; };
|
||||||
|
|
||||||
void removeDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void removeDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void addDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void addDelegate(std::function<void(CCAcceleration*)> function) {CC_UNUSED_PARAM(function);};
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
void setDelegate(CCAccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
|
||||||
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,8 +30,8 @@ using namespace Tizen::Uix::Sensor;
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer()
|
CCAccelerometer::CCAccelerometer()
|
||||||
: _accelDelegate(NULL)
|
: _function(nullptr)
|
||||||
, __sensorMgr(NULL)
|
, __sensorMgr(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ CCAccelerometer::~CCAccelerometer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
void CCAccelerometer::setDelegate(std::function<void(CCAcceleration*)> function)
|
||||||
{
|
{
|
||||||
_accelDelegate = pDelegate;
|
_function = function;
|
||||||
|
|
||||||
if (pDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
startSensor();
|
startSensor();
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ void CCAccelerometer::stopSensor()
|
||||||
|
|
||||||
void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorData , result r)
|
void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorData , result r)
|
||||||
{
|
{
|
||||||
if (_accelDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
AccelerationSensorData& data = static_cast<AccelerationSensorData&>(sensorData);
|
AccelerationSensorData& data = static_cast<AccelerationSensorData&>(sensorData);
|
||||||
AppLog("AccelerationSensorData x = %5.4f , y = %5.4f, z = %5.4f ", data.x,data.y,data.z);
|
AppLog("AccelerationSensorData x = %5.4f , y = %5.4f, z = %5.4f ", data.x,data.y,data.z);
|
||||||
|
@ -107,7 +107,7 @@ void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorDa
|
||||||
_accelerationValue.z = -data.z;
|
_accelerationValue.z = -data.z;
|
||||||
_accelerationValue.timestamp = data.timestamp;
|
_accelerationValue.timestamp = data.timestamp;
|
||||||
|
|
||||||
_accelDelegate->didAccelerate(&_accelerationValue);
|
_function(&_accelerationValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
#include <FUix.h>
|
#include <FUix.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public:
|
||||||
CCAccelerometer();
|
CCAccelerometer();
|
||||||
~CCAccelerometer();
|
~CCAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(std::function<void(CCAcceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval);
|
void setAccelerometerInterval(float interval);
|
||||||
void startSensor();
|
void startSensor();
|
||||||
void stopSensor();
|
void stopSensor();
|
||||||
|
@ -46,7 +47,7 @@ public:
|
||||||
virtual void OnDataReceived(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData , result r);
|
virtual void OnDataReceived(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData , result r);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CCAccelerometerDelegate* _accelDelegate;
|
std::function<void(CCAcceleration*)> _function;
|
||||||
CCAcceleration _accelerationValue;
|
CCAcceleration _accelerationValue;
|
||||||
Tizen::Uix::Sensor::SensorManager* __sensorMgr;
|
Tizen::Uix::Sensor::SensorManager* __sensorMgr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer() :
|
CCAccelerometer::CCAccelerometer() :
|
||||||
_accelDelegate(NULL)
|
_function(nullptr)
|
||||||
{
|
{
|
||||||
memset(&_accelerationValue, 0, sizeof(_accelerationValue));
|
memset(&_accelerationValue, 0, sizeof(_accelerationValue));
|
||||||
}
|
}
|
||||||
|
@ -158,14 +158,14 @@ CCAccelerometer::~CCAccelerometer()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
void CCAccelerometer::setDelegate(std::function<void(CCAcceleration*)> function)
|
||||||
{
|
{
|
||||||
_accelDelegate = pDelegate;
|
_function = function;
|
||||||
|
|
||||||
// Enable/disable the accelerometer.
|
// Enable/disable the accelerometer.
|
||||||
// Well, there isn't one on Win32 so we don't do anything other than register
|
// Well, there isn't one on Win32 so we don't do anything other than register
|
||||||
// and deregister ourselves from the Windows Key handler.
|
// and deregister ourselves from the Windows Key handler.
|
||||||
if (pDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
// Register our handler
|
// Register our handler
|
||||||
CCEGLView::sharedOpenGLView()->setAccelerometerKeyHook( &myAccelerometerKeyHook );
|
CCEGLView::sharedOpenGLView()->setAccelerometerKeyHook( &myAccelerometerKeyHook );
|
||||||
|
@ -185,7 +185,7 @@ void CCAccelerometer::setAccelerometerInterval(float interval)
|
||||||
|
|
||||||
void CCAccelerometer::update( double x,double y,double z,double timestamp )
|
void CCAccelerometer::update( double x,double y,double z,double timestamp )
|
||||||
{
|
{
|
||||||
if (_accelDelegate)
|
if (_function)
|
||||||
{
|
{
|
||||||
_accelerationValue.x = x;
|
_accelerationValue.x = x;
|
||||||
_accelerationValue.y = y;
|
_accelerationValue.y = y;
|
||||||
|
@ -193,7 +193,7 @@ void CCAccelerometer::update( double x,double y,double z,double timestamp )
|
||||||
_accelerationValue.timestamp = timestamp;
|
_accelerationValue.timestamp = timestamp;
|
||||||
|
|
||||||
// Delegate
|
// Delegate
|
||||||
_accelDelegate->didAccelerate(&_accelerationValue);
|
_function(&_accelerationValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ THE SOFTWARE.
|
||||||
#define __PLATFORM_WIN32_UIACCELEROMETER_H__
|
#define __PLATFORM_WIN32_UIACCELEROMETER_H__
|
||||||
|
|
||||||
#include "platform/CCAccelerometerDelegate.h"
|
#include "platform/CCAccelerometerDelegate.h"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
@ -35,12 +36,12 @@ public:
|
||||||
CCAccelerometer();
|
CCAccelerometer();
|
||||||
~CCAccelerometer();
|
~CCAccelerometer();
|
||||||
|
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(std::function<void(CCAcceleration*)> function);
|
||||||
void setAccelerometerInterval(float interval);
|
void setAccelerometerInterval(float interval);
|
||||||
void update( double x,double y,double z,double timestamp );
|
void update( double x,double y,double z,double timestamp );
|
||||||
private:
|
private:
|
||||||
CCAcceleration _accelerationValue;
|
CCAcceleration _accelerationValue;
|
||||||
CCAccelerometerDelegate* _accelDelegate;
|
std::function<void(CCAcceleration*)> _function;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
06a3716ff2fdcaa883bed71ffe53793daf0f3980
|
08c5c5cd8dcd5b6d72678c72cd156682e33f8553
|
|
@ -174,11 +174,11 @@ void CCInputDelegate::setAccelerometerEnabled(bool enabled)
|
||||||
CCDirector* pDirector = CCDirector::sharedDirector();
|
CCDirector* pDirector = CCDirector::sharedDirector();
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
pDirector->getAccelerometer()->setDelegate(this);
|
pDirector->getAccelerometer()->setDelegate(CC_CALLBACK_1(CCInputDelegate::didAccelerate, this));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pDirector->getAccelerometer()->setDelegate(NULL);
|
pDirector->getAccelerometer()->setDelegate(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_EXT_BEGIN
|
NS_CC_EXT_BEGIN
|
||||||
|
|
||||||
class CCInputDelegate : public CCTouchDelegate, public CCAccelerometerDelegate, public CCKeypadDelegate
|
class CCInputDelegate : public CCTouchDelegate, public CCKeypadDelegate
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
CCInputDelegate(void);
|
CCInputDelegate(void);
|
||||||
|
|
|
@ -281,7 +281,7 @@ bool WebSocket::init(const Delegate& delegate,
|
||||||
port = atoi(host.substr(pos+1, host.size()).c_str());
|
port = atoi(host.substr(pos+1, host.size()).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = host.find("/", pos);
|
pos = host.find("/", 0);
|
||||||
std::string path = "/";
|
std::string path = "/";
|
||||||
if(pos >= 0){
|
if(pos >= 0){
|
||||||
path += host.substr(pos + 1, host.size());
|
path += host.substr(pos + 1, host.size());
|
||||||
|
@ -290,14 +290,17 @@ bool WebSocket::init(const Delegate& delegate,
|
||||||
pos = host.find(":");
|
pos = host.find(":");
|
||||||
if(pos >= 0){
|
if(pos >= 0){
|
||||||
host.erase(pos, host.size());
|
host.erase(pos, host.size());
|
||||||
|
}else if((pos = host.find("/"))>=0) {
|
||||||
|
host.erase(pos, host.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_host = host;
|
_host = host;
|
||||||
_port = port;
|
_port = port;
|
||||||
_path = path;
|
_path = path;
|
||||||
_SSLConnection = useSSL ? 1 : 0;
|
_SSLConnection = useSSL ? 1 : 0;
|
||||||
|
|
||||||
|
CCLOG("[WebSocket::init] _host: %s, _port: %d, _path: %s", _host.c_str(), _port, _path.c_str());
|
||||||
|
|
||||||
int protocolCount = 0;
|
int protocolCount = 0;
|
||||||
if (protocols && protocols->size() > 0)
|
if (protocols && protocols->size() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,4 +94,5 @@ tools/toolsForPublish/environment.sh
|
||||||
.settings
|
.settings
|
||||||
plugins/china*
|
plugins/china*
|
||||||
plugins/punchbox*
|
plugins/punchbox*
|
||||||
|
plugins/touchpay*
|
||||||
samplesPrivate*
|
samplesPrivate*
|
||||||
|
|
|
@ -99,6 +99,9 @@ public class AdsAdmob implements InterfaceAds {
|
||||||
case AdsWrapper.ADS_TYPE_FULL_SCREEN:
|
case AdsWrapper.ADS_TYPE_FULL_SCREEN:
|
||||||
LogD("Now not support full screen view in Admob");
|
LogD("Now not support full screen view in Admob");
|
||||||
break;
|
break;
|
||||||
|
case AdsWrapper.ADS_TYPE_MORE_APP:
|
||||||
|
LogD("Now not support more app ads in Admob");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +109,7 @@ public class AdsAdmob implements InterfaceAds {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spendPoints(int points) {
|
public void spendPoints(int points) {
|
||||||
// do nothing, Admob don't have this function
|
LogD("Admob not support spend points!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -213,7 +216,7 @@ public class AdsAdmob implements InterfaceAds {
|
||||||
@Override
|
@Override
|
||||||
public void onDismissScreen(Ad arg0) {
|
public void onDismissScreen(Ad arg0) {
|
||||||
LogD("onDismissScreen invoked");
|
LogD("onDismissScreen invoked");
|
||||||
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewDismissed, "Full screen ads view dismissed!");
|
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsDismissed, "Ads view dismissed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -247,7 +250,7 @@ public class AdsAdmob implements InterfaceAds {
|
||||||
@Override
|
@Override
|
||||||
public void onPresentScreen(Ad arg0) {
|
public void onPresentScreen(Ad arg0) {
|
||||||
LogD("onPresentScreen invoked");
|
LogD("onPresentScreen invoked");
|
||||||
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_FullScreenViewShown, "Full screen ads view shown!");
|
AdsWrapper.onAdsResult(mAdapter, AdsWrapper.RESULT_CODE_AdsShown, "Ads view shown!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -261,4 +264,9 @@ public class AdsAdmob implements InterfaceAds {
|
||||||
public String getPluginVersion() {
|
public String getPluginVersion() {
|
||||||
return "0.2.0";
|
return "0.2.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryPoints() {
|
||||||
|
LogD("Admob not support query points!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef enum {
|
||||||
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
|
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
|
||||||
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
|
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
|
||||||
- (void) hideAds: (int) type;
|
- (void) hideAds: (int) type;
|
||||||
|
- (void) queryPoints;
|
||||||
- (void) spendPoints: (int) points;
|
- (void) spendPoints: (int) points;
|
||||||
- (void) setDebugMode: (BOOL) isDebugMode;
|
- (void) setDebugMode: (BOOL) isDebugMode;
|
||||||
- (NSString*) getSDKVersion;
|
- (NSString*) getSDKVersion;
|
||||||
|
|
|
@ -62,10 +62,18 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == kTypeBanner) {
|
switch (type) {
|
||||||
|
case kTypeBanner:
|
||||||
[self showBanner:sizeEnum atPos:pos];
|
[self showBanner:sizeEnum atPos:pos];
|
||||||
} else {
|
break;
|
||||||
|
case kTypeFullScreen:
|
||||||
OUTPUT_LOG(@"Now not support full screen view in Admob");
|
OUTPUT_LOG(@"Now not support full screen view in Admob");
|
||||||
|
break;
|
||||||
|
case kTypeMoreApp:
|
||||||
|
OUTPUT_LOG(@"Now not support more app ads in Admob");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,9 +90,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) queryPoints
|
||||||
|
{
|
||||||
|
OUTPUT_LOG(@"Admob not support query points!");
|
||||||
|
}
|
||||||
|
|
||||||
- (void) spendPoints: (int) points
|
- (void) spendPoints: (int) points
|
||||||
{
|
{
|
||||||
|
OUTPUT_LOG(@"Admob not support spend points!");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setDebugMode: (BOOL) isDebugMode
|
- (void) setDebugMode: (BOOL) isDebugMode
|
||||||
|
|
|
@ -36,8 +36,8 @@ typedef enum
|
||||||
{
|
{
|
||||||
kAdsReceived = 0, // The ad is received
|
kAdsReceived = 0, // The ad is received
|
||||||
|
|
||||||
kFullScreenViewShown, // The full screen advertisement shown
|
kAdsShown, // The advertisement shown
|
||||||
kFullScreenViewDismissed, // The full screen advertisement dismissed
|
kAdsDismissed, // The advertisement dismissed
|
||||||
|
|
||||||
kPointsSpendSucceed, // The points spend succeed
|
kPointsSpendSucceed, // The points spend succeed
|
||||||
kPointsSpendFailed, // The points spend failed
|
kPointsSpendFailed, // The points spend failed
|
||||||
|
@ -72,6 +72,7 @@ public:
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kBannerAd = 0,
|
kBannerAd = 0,
|
||||||
kFullScreenAd,
|
kFullScreenAd,
|
||||||
|
kMoreApp,
|
||||||
} AdsType;
|
} AdsType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -111,6 +112,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void hideAds(AdsType type);
|
void hideAds(AdsType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Query the points of player
|
||||||
|
*/
|
||||||
|
void queryPoints();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Spend the points.
|
@brief Spend the points.
|
||||||
Use this method to notify server spend points.
|
Use this method to notify server spend points.
|
||||||
|
|
|
@ -119,6 +119,11 @@ void ProtocolAds::hideAds(AdsType type)
|
||||||
PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type);
|
PluginUtils::callJavaFunctionWithName_oneParam(this, "hideAds", "(I)V", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProtocolAds::queryPoints()
|
||||||
|
{
|
||||||
|
PluginUtils::callJavaFunctionWithName(this, "queryPoints");
|
||||||
|
}
|
||||||
|
|
||||||
void ProtocolAds::spendPoints(int points)
|
void ProtocolAds::spendPoints(int points)
|
||||||
{
|
{
|
||||||
PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points);
|
PluginUtils::callJavaFunctionWithName_oneParam(this, "spendPoints", "(I)V", points);
|
||||||
|
|
|
@ -28,8 +28,8 @@ THE SOFTWARE.
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kAdsReceived = 0,
|
kAdsReceived = 0,
|
||||||
|
|
||||||
kFullScreenViewShown,
|
kAdsShown,
|
||||||
kFullScreenViewDismissed,
|
kAdsDismissed,
|
||||||
|
|
||||||
kPointsSpendSucceed,
|
kPointsSpendSucceed,
|
||||||
kPointsSpendFailed,
|
kPointsSpendFailed,
|
||||||
|
@ -41,6 +41,7 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kTypeBanner = 0,
|
kTypeBanner = 0,
|
||||||
kTypeFullScreen,
|
kTypeFullScreen,
|
||||||
|
kTypeMoreApp,
|
||||||
} AdsTypeEnum;
|
} AdsTypeEnum;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||||
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
|
- (void) configDeveloperInfo: (NSMutableDictionary*) devInfo;
|
||||||
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
|
- (void) showAds: (int) type size:(int) sizeEnum position:(int) pos;
|
||||||
- (void) hideAds: (int) type;
|
- (void) hideAds: (int) type;
|
||||||
|
- (void) queryPoints;
|
||||||
- (void) spendPoints: (int) points;
|
- (void) spendPoints: (int) points;
|
||||||
- (void) setDebugMode: (BOOL) debug;
|
- (void) setDebugMode: (BOOL) debug;
|
||||||
- (NSString*) getSDKVersion;
|
- (NSString*) getSDKVersion;
|
||||||
|
|
|
@ -30,8 +30,8 @@ import android.view.WindowManager;
|
||||||
public class AdsWrapper {
|
public class AdsWrapper {
|
||||||
|
|
||||||
public static final int RESULT_CODE_AdsReceived = 0; // The ad is received
|
public static final int RESULT_CODE_AdsReceived = 0; // The ad is received
|
||||||
public static final int RESULT_CODE_FullScreenViewShown = 1; // The full screen advertisement shown
|
public static final int RESULT_CODE_AdsShown = 1; // The advertisement shown
|
||||||
public static final int RESULT_CODE_FullScreenViewDismissed = 2; // The full screen advertisement dismissed
|
public static final int RESULT_CODE_AdsDismissed = 2; // The advertisement dismissed
|
||||||
public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed
|
public static final int RESULT_CODE_PointsSpendSucceed = 3; // The points spend succeed
|
||||||
public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed
|
public static final int RESULT_CODE_PointsSpendFailed = 4; // The points spend failed
|
||||||
public static final int RESULT_CODE_NetworkError = 5; // Network error
|
public static final int RESULT_CODE_NetworkError = 5; // Network error
|
||||||
|
@ -39,6 +39,7 @@ public class AdsWrapper {
|
||||||
|
|
||||||
public static final int ADS_TYPE_BANNER = 0;
|
public static final int ADS_TYPE_BANNER = 0;
|
||||||
public static final int ADS_TYPE_FULL_SCREEN = 1;
|
public static final int ADS_TYPE_FULL_SCREEN = 1;
|
||||||
|
public static final int ADS_TYPE_MORE_APP = 2;
|
||||||
|
|
||||||
public static final int POS_CENTER = 0;
|
public static final int POS_CENTER = 0;
|
||||||
public static final int POS_TOP = 1;
|
public static final int POS_TOP = 1;
|
||||||
|
|
|
@ -32,6 +32,7 @@ public interface InterfaceAds {
|
||||||
public void configDeveloperInfo(Hashtable<String, String> devInfo);
|
public void configDeveloperInfo(Hashtable<String, String> devInfo);
|
||||||
public void showAds(int type, int sizeEnum, int pos);
|
public void showAds(int type, int sizeEnum, int pos);
|
||||||
public void hideAds(int type);
|
public void hideAds(int type);
|
||||||
|
public void queryPoints();
|
||||||
public void spendPoints(int points);
|
public void spendPoints(int points);
|
||||||
public void setDebugMode(boolean debug);
|
public void setDebugMode(boolean debug);
|
||||||
public String getSDKVersion();
|
public String getSDKVersion();
|
||||||
|
|
|
@ -34,6 +34,7 @@ const std::string s_aTestCases[] = {
|
||||||
const std::string s_aTestTypes[] = {
|
const std::string s_aTestTypes[] = {
|
||||||
"Banner",
|
"Banner",
|
||||||
"Full Screen",
|
"Full Screen",
|
||||||
|
"More App",
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string s_aTestPoses[] = {
|
const std::string s_aTestPoses[] = {
|
||||||
|
|
Loading…
Reference in New Issue