mirror of https://github.com/axmolengine/axmol.git
issue #2087: Updating the constructor of XXXEvent.
This commit is contained in:
parent
6f53dcb49f
commit
e697b0fc0b
|
@ -28,8 +28,10 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
const char* AccelerationEvent::EVENT_TYPE = "AccelerometerEvent";
|
const char* AccelerationEvent::EVENT_TYPE = "AccelerometerEvent";
|
||||||
|
|
||||||
AccelerationEvent::AccelerationEvent()
|
AccelerationEvent::AccelerationEvent(Acceleration acc)
|
||||||
: Event(EVENT_TYPE)
|
: Event(EVENT_TYPE)
|
||||||
{}
|
, _acc(acc)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -35,8 +35,10 @@ class AccelerationEvent : public Event
|
||||||
public:
|
public:
|
||||||
static const char* EVENT_TYPE;
|
static const char* EVENT_TYPE;
|
||||||
|
|
||||||
AccelerationEvent();
|
AccelerationEvent(Acceleration acc);
|
||||||
Acceleration acc;
|
|
||||||
|
private:
|
||||||
|
Acceleration _acc;
|
||||||
};
|
};
|
||||||
|
|
||||||
NS_CC_END
|
NS_CC_END
|
||||||
|
|
|
@ -198,7 +198,13 @@ public:
|
||||||
|
|
||||||
static const char* EVENT_TYPE;
|
static const char* EVENT_TYPE;
|
||||||
|
|
||||||
KeyboardEvent() : Event(EVENT_TYPE) {};
|
KeyboardEvent(KeyCode keyCode, bool isPressed)
|
||||||
|
: Event(EVENT_TYPE)
|
||||||
|
, _keyCode(keyCode)
|
||||||
|
, _isPressed(isPressed)
|
||||||
|
{};
|
||||||
|
|
||||||
|
private:
|
||||||
KeyCode _keyCode;
|
KeyCode _keyCode;
|
||||||
bool _isPressed;
|
bool _isPressed;
|
||||||
};
|
};
|
||||||
|
|
|
@ -400,17 +400,13 @@ static int32_t handle_key_input(AInputEvent *event)
|
||||||
{
|
{
|
||||||
case AKEYCODE_BACK:
|
case AKEYCODE_BACK:
|
||||||
{
|
{
|
||||||
cocos2d::KeyboardEvent event;
|
cocos2d::KeyboardEvent event(cocos2d::KeyboardEvent::KeyCode::KEY_BACKSPACE, false);
|
||||||
event._keyCode = cocos2d::KeyboardEvent::KeyCode::KEY_BACKSPACE;
|
|
||||||
event._isPressed = false;
|
|
||||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
case AKEYCODE_MENU:
|
case AKEYCODE_MENU:
|
||||||
{
|
{
|
||||||
cocos2d::KeyboardEvent event;
|
cocos2d::KeyboardEvent event(cocos2d::KeyboardEvent::KeyCode::KEY_MENU, false);
|
||||||
event._keyCode = cocos2d::KeyboardEvent::KeyCode::KEY_MENU;
|
|
||||||
event._isPressed = false;
|
|
||||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -601,21 +597,24 @@ void android_main(struct android_app* state) {
|
||||||
// ACONFIGURATION_ORIENTATION_ANY
|
// ACONFIGURATION_ORIENTATION_ANY
|
||||||
// ACONFIGURATION_ORIENTATION_PORT
|
// ACONFIGURATION_ORIENTATION_PORT
|
||||||
// ACONFIGURATION_ORIENTATION_SQUARE
|
// ACONFIGURATION_ORIENTATION_SQUARE
|
||||||
cocos2d::AccelerationEvent accEvent;
|
cocos2d::Acceleration acc;
|
||||||
accEvent.acc.x = event.acceleration.x;
|
acc.x = event.acceleration.x;
|
||||||
accEvent.acc.y = event.acceleration.y;
|
acc.y = event.acceleration.y;
|
||||||
accEvent.acc.z = event.acceleration.z;
|
acc.z = event.acceleration.z;
|
||||||
accEvent.acc.timestamp = 0;
|
acc.timestamp = 0;
|
||||||
|
cocos2d::AccelerationEvent accEvent(acc);
|
||||||
|
|
||||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
|
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
|
||||||
} else {
|
} else {
|
||||||
// ACONFIGURATION_ORIENTATION_LAND
|
// ACONFIGURATION_ORIENTATION_LAND
|
||||||
// swap x and y parameters
|
// swap x and y parameters
|
||||||
|
cocos2d::Acceleration acc;
|
||||||
|
acc.x = -event.acceleration.y;
|
||||||
|
acc.y = event.acceleration.x;
|
||||||
|
acc.z = event.acceleration.z;
|
||||||
|
acc.timestamp = 0;
|
||||||
|
cocos2d::AccelerationEvent accEvent(acc);
|
||||||
|
|
||||||
cocos2d::AccelerationEvent accEvent;
|
|
||||||
accEvent.acc.x = -event.acceleration.y;
|
|
||||||
accEvent.acc.y = event.acceleration.x;
|
|
||||||
accEvent.acc.z = event.acceleration.z;
|
|
||||||
accEvent.acc.timestamp = 0;
|
|
||||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
|
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cocos2d::AccelerationEvent event;
|
cocos2d::AccelerationEvent event(*_acceleration);
|
||||||
event.acc = *_acceleration;
|
|
||||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,9 +222,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
||||||
|
|
||||||
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
KeyboardEvent event;
|
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action);
|
||||||
event._keyCode = g_keyCodeMap[key];
|
|
||||||
event._isPressed = (GLFW_PRESS == action);
|
|
||||||
EventDispatcher::getInstance()->dispatchEvent(&event);
|
EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,9 +238,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
||||||
|
|
||||||
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
KeyboardEvent event;
|
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action);
|
||||||
event._keyCode = g_keyCodeMap[key];
|
|
||||||
event._isPressed = (GLFW_PRESS == action);
|
|
||||||
EventDispatcher::getInstance()->dispatchEvent(&event);
|
EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,9 +340,7 @@ void EGLViewEventHandler::OnGLFWMouseMoveCallBack(GLFWwindow* window, double x,
|
||||||
|
|
||||||
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
KeyboardEvent event;
|
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action);
|
||||||
event._keyCode = g_keyCodeMap[key];
|
|
||||||
event._isPressed = (GLFW_PRESS == action);
|
|
||||||
EventDispatcher::getInstance()->dispatchEvent(&event);
|
EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue