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";
|
||||
|
||||
AccelerationEvent::AccelerationEvent()
|
||||
AccelerationEvent::AccelerationEvent(Acceleration acc)
|
||||
: Event(EVENT_TYPE)
|
||||
{}
|
||||
, _acc(acc)
|
||||
{
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -35,8 +35,10 @@ class AccelerationEvent : public Event
|
|||
public:
|
||||
static const char* EVENT_TYPE;
|
||||
|
||||
AccelerationEvent();
|
||||
Acceleration acc;
|
||||
AccelerationEvent(Acceleration acc);
|
||||
|
||||
private:
|
||||
Acceleration _acc;
|
||||
};
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -198,7 +198,13 @@ public:
|
|||
|
||||
static const char* EVENT_TYPE;
|
||||
|
||||
KeyboardEvent() : Event(EVENT_TYPE) {};
|
||||
KeyboardEvent(KeyCode keyCode, bool isPressed)
|
||||
: Event(EVENT_TYPE)
|
||||
, _keyCode(keyCode)
|
||||
, _isPressed(isPressed)
|
||||
{};
|
||||
|
||||
private:
|
||||
KeyCode _keyCode;
|
||||
bool _isPressed;
|
||||
};
|
||||
|
|
|
@ -400,17 +400,13 @@ static int32_t handle_key_input(AInputEvent *event)
|
|||
{
|
||||
case AKEYCODE_BACK:
|
||||
{
|
||||
cocos2d::KeyboardEvent event;
|
||||
event._keyCode = cocos2d::KeyboardEvent::KeyCode::KEY_BACKSPACE;
|
||||
event._isPressed = false;
|
||||
cocos2d::KeyboardEvent event(cocos2d::KeyboardEvent::KeyCode::KEY_BACKSPACE, false);
|
||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||
}
|
||||
return 1;
|
||||
case AKEYCODE_MENU:
|
||||
{
|
||||
cocos2d::KeyboardEvent event;
|
||||
event._keyCode = cocos2d::KeyboardEvent::KeyCode::KEY_MENU;
|
||||
event._isPressed = false;
|
||||
cocos2d::KeyboardEvent event(cocos2d::KeyboardEvent::KeyCode::KEY_MENU, false);
|
||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||
}
|
||||
return 1;
|
||||
|
@ -601,21 +597,24 @@ void android_main(struct android_app* state) {
|
|||
// ACONFIGURATION_ORIENTATION_ANY
|
||||
// ACONFIGURATION_ORIENTATION_PORT
|
||||
// ACONFIGURATION_ORIENTATION_SQUARE
|
||||
cocos2d::AccelerationEvent accEvent;
|
||||
accEvent.acc.x = event.acceleration.x;
|
||||
accEvent.acc.y = event.acceleration.y;
|
||||
accEvent.acc.z = event.acceleration.z;
|
||||
accEvent.acc.timestamp = 0;
|
||||
cocos2d::Acceleration acc;
|
||||
acc.x = event.acceleration.x;
|
||||
acc.y = event.acceleration.y;
|
||||
acc.z = event.acceleration.z;
|
||||
acc.timestamp = 0;
|
||||
cocos2d::AccelerationEvent accEvent(acc);
|
||||
|
||||
cocos2d::EventDispatcher::getInstance()->dispatchEvent(&accEvent);
|
||||
} else {
|
||||
// ACONFIGURATION_ORIENTATION_LAND
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,8 +95,7 @@ static CCAccelerometerDispatcher* s_pAccelerometerDispatcher;
|
|||
break;
|
||||
}
|
||||
|
||||
cocos2d::AccelerationEvent event;
|
||||
event.acc = *_acceleration;
|
||||
cocos2d::AccelerationEvent event(*_acceleration);
|
||||
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)
|
||||
{
|
||||
KeyboardEvent event;
|
||||
event._keyCode = g_keyCodeMap[key];
|
||||
event._isPressed = (GLFW_PRESS == action);
|
||||
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action);
|
||||
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)
|
||||
{
|
||||
KeyboardEvent event;
|
||||
event._keyCode = g_keyCodeMap[key];
|
||||
event._isPressed = (GLFW_PRESS == action);
|
||||
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action);
|
||||
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)
|
||||
{
|
||||
KeyboardEvent event;
|
||||
event._keyCode = g_keyCodeMap[key];
|
||||
event._isPressed = (GLFW_PRESS == action);
|
||||
KeyboardEvent event(g_keyCodeMap[key], GLFW_PRESS == action);
|
||||
EventDispatcher::getInstance()->dispatchEvent(&event);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue