mirror of https://github.com/axmolengine/axmol.git
add scale support
This commit is contained in:
parent
1830b4e2e9
commit
beaa489406
|
@ -69,6 +69,15 @@ bool AppDelegate::initInstance() {
|
||||||
CCFileUtils::setResourcePath("../Resource/");
|
CCFileUtils::setResourcePath("../Resource/");
|
||||||
|
|
||||||
#endif // CC_PLATFORM_LINUX
|
#endif // CC_PLATFORM_LINUX
|
||||||
|
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||||
|
|
||||||
|
CCEGLView * pMainWnd = new CCEGLView();
|
||||||
|
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
|
||||||
|
CCFileUtils::setResourcePath("/Res/");
|
||||||
|
|
||||||
|
#endif // CC_PLATFORM_BADA
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
} while (0);
|
} while (0);
|
||||||
return bRet;
|
return bRet;
|
||||||
|
@ -85,7 +94,9 @@ bool AppDelegate::applicationDidFinishLaunching() {
|
||||||
|
|
||||||
// turn on display FPS
|
// turn on display FPS
|
||||||
pDirector->setDisplayFPS(true);
|
pDirector->setDisplayFPS(true);
|
||||||
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||||
|
pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||||
|
#endif
|
||||||
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
// pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
|
||||||
|
|
||||||
// set FPS. the default value is 1.0/60 if you don't call this
|
// set FPS. the default value is 1.0/60 if you don't call this
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||||
<entry excluding="src" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name=""/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Classes"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
@ -568,7 +568,8 @@
|
||||||
</toolChain>
|
</toolChain>
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Classes"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
@ -1064,7 +1065,8 @@
|
||||||
</toolChain>
|
</toolChain>
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Classes"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
|
|
@ -82,14 +82,9 @@
|
||||||
</natures>
|
</natures>
|
||||||
<linkedResources>
|
<linkedResources>
|
||||||
<link>
|
<link>
|
||||||
<name>AppDelegate.cpp</name>
|
<name>Classes</name>
|
||||||
<type>1</type>
|
<type>2</type>
|
||||||
<locationURI>cocos2dx_root/HelloWorld/AppDelegate.cpp</locationURI>
|
<locationURI>cocos2dx_root/HelloWorld/Classes</locationURI>
|
||||||
</link>
|
|
||||||
<link>
|
|
||||||
<name>HelloWorldScene.cpp</name>
|
|
||||||
<type>1</type>
|
|
||||||
<locationURI>cocos2dx_root/HelloWorld/HelloWorldScene.cpp</locationURI>
|
|
||||||
</link>
|
</link>
|
||||||
<link>
|
<link>
|
||||||
<name>src</name>
|
<name>src</name>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* This file contains the bada application entry point.
|
* This file contains the bada application entry point.
|
||||||
*/
|
*/
|
||||||
#include "../../AppDelegate.h"
|
#include "../../Classes/AppDelegate.h"
|
||||||
|
|
||||||
using namespace Osp::Base;
|
using namespace Osp::Base;
|
||||||
using namespace Osp::Base::Collection;
|
using namespace Osp::Base::Collection;
|
||||||
|
|
|
@ -31,8 +31,11 @@ NS_CC_BEGIN;
|
||||||
|
|
||||||
CCAccelerometer* CCAccelerometer::m_spCCAccelerometer = NULL;
|
CCAccelerometer* CCAccelerometer::m_spCCAccelerometer = NULL;
|
||||||
|
|
||||||
CCAccelerometer::CCAccelerometer() : m_pAccelDelegate(NULL)
|
CCAccelerometer::CCAccelerometer() :
|
||||||
|
m_pAccelDelegate(NULL)
|
||||||
|
, m_pSensor(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CCAccelerometer::~CCAccelerometer()
|
CCAccelerometer::~CCAccelerometer()
|
||||||
|
@ -52,6 +55,14 @@ CCAccelerometer* CCAccelerometer::sharedAccelerometer()
|
||||||
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate)
|
||||||
{
|
{
|
||||||
m_pAccelDelegate = pDelegate;
|
m_pAccelDelegate = pDelegate;
|
||||||
|
if (pDelegate)
|
||||||
|
{
|
||||||
|
setEnable(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEnable(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorData, result r)
|
void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorData, result r)
|
||||||
|
@ -64,14 +75,47 @@ void CCAccelerometer::OnDataReceived(SensorType sensorType, SensorData& sensorDa
|
||||||
sensorData.GetValue((SensorDataKey)ACCELERATION_DATA_KEY_Y, y);
|
sensorData.GetValue((SensorDataKey)ACCELERATION_DATA_KEY_Y, y);
|
||||||
sensorData.GetValue((SensorDataKey)ACCELERATION_DATA_KEY_Z, z);
|
sensorData.GetValue((SensorDataKey)ACCELERATION_DATA_KEY_Z, z);
|
||||||
|
|
||||||
|
// only consider land postion, to be continued.
|
||||||
CCAcceleration AccValue;
|
CCAcceleration AccValue;
|
||||||
AccValue.x = -x;
|
AccValue.x = y;
|
||||||
AccValue.y = -y;
|
AccValue.y = -x;
|
||||||
AccValue.z = -z;
|
AccValue.z = z;
|
||||||
AccValue.timestamp = timeStamp;
|
AccValue.timestamp = timeStamp;
|
||||||
|
|
||||||
m_pAccelDelegate->didAccelerate(&AccValue);
|
m_pAccelDelegate->didAccelerate(&AccValue);
|
||||||
AppLog("####################TimeStamp:[%d], Accel.x,y,z:[%f,%f,%f]", timeStamp, x, y, z);
|
AppLog("##TimeStamp:[%d], Accel.x,y,z:[%f,%f,%f]", timeStamp, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCAccelerometer::setEnable(bool bEnable)
|
||||||
|
{
|
||||||
|
if (m_pSensor != NULL)
|
||||||
|
{
|
||||||
|
m_pSensor->RemoveSensorListener(*this);
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(m_pSensor);
|
||||||
|
if (bEnable)
|
||||||
|
{
|
||||||
|
long interval = 10;
|
||||||
|
bool available = false;
|
||||||
|
result r = E_INVALID_STATE;
|
||||||
|
m_pSensor = new SensorManager();
|
||||||
|
m_pSensor->Construct();
|
||||||
|
|
||||||
|
available = m_pSensor->IsAvailable(SENSOR_TYPE_ACCELERATION);
|
||||||
|
|
||||||
|
if (available)
|
||||||
|
{
|
||||||
|
long intervalTemp = 0;
|
||||||
|
m_pSensor->GetMaxInterval(SENSOR_TYPE_ACCELERATION, intervalTemp);
|
||||||
|
if (interval > intervalTemp)
|
||||||
|
interval = intervalTemp;
|
||||||
|
m_pSensor->GetMinInterval(SENSOR_TYPE_ACCELERATION, intervalTemp);
|
||||||
|
if (interval < intervalTemp)
|
||||||
|
interval = intervalTemp;
|
||||||
|
|
||||||
|
r = m_pSensor->AddSensorListener(*this, SENSOR_TYPE_ACCELERATION, interval, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_CC_END;
|
NS_CC_END;
|
||||||
|
|
|
@ -45,8 +45,11 @@ public:
|
||||||
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
void setDelegate(CCAccelerometerDelegate* pDelegate);
|
||||||
virtual void OnDataReceived(Osp::Uix::SensorType sensorType, Osp::Uix::SensorData& sensorData , result r);
|
virtual void OnDataReceived(Osp::Uix::SensorType sensorType, Osp::Uix::SensorData& sensorData , result r);
|
||||||
private:
|
private:
|
||||||
|
void setEnable(bool bEnable);
|
||||||
|
|
||||||
static CCAccelerometer* m_spCCAccelerometer;
|
static CCAccelerometer* m_spCCAccelerometer;
|
||||||
CCAccelerometerDelegate* m_pAccelDelegate;
|
CCAccelerometerDelegate* m_pAccelDelegate;
|
||||||
|
Osp::Uix::SensorManager* m_pSensor;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace cocos2d
|
}//namespace cocos2d
|
||||||
|
|
|
@ -172,8 +172,6 @@ private:
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// impliment CCEGLView
|
// impliment CCEGLView
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
CCEGLView::CCEGLView()
|
CCEGLView::CCEGLView()
|
||||||
: m_bNotHVGA(true)
|
: m_bNotHVGA(true)
|
||||||
, m_pDelegate(NULL)
|
, m_pDelegate(NULL)
|
||||||
|
@ -198,55 +196,7 @@ CCEGLView::~CCEGLView()
|
||||||
|
|
||||||
CCSize CCEGLView::getSize()
|
CCSize CCEGLView::getSize()
|
||||||
{
|
{
|
||||||
CCSize s;
|
return CCSize((float)(m_sSizeInPoint.width), (float)(m_sSizeInPoint.height));
|
||||||
// if (m_nowOrientation == ORIENTATION_PORTRAIT || m_nowOrientation == ORIENTATION_PORTRAIT_REVERSE)
|
|
||||||
// {
|
|
||||||
// if (m_bNotHVGA)
|
|
||||||
// {
|
|
||||||
// s = CCSizeMake(480, 800);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// s = CCSizeMake(320, 480);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if (m_bNotHVGA)
|
|
||||||
// {
|
|
||||||
// s = CCSizeMake(800, 480);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// s = CCSizeMake(480, 320);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
if (m_nowOrientation == ORIENTATION_PORTRAIT || m_nowOrientation == ORIENTATION_PORTRAIT_REVERSE)
|
|
||||||
{
|
|
||||||
if (m_bNotHVGA)
|
|
||||||
{
|
|
||||||
s = CCSizeMake(MIN(m_sSizeInPoint.width, m_sSizeInPoint.height), MAX(m_sSizeInPoint.width, m_sSizeInPoint.height));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = CCSizeMake(MIN(m_sSizeInPixel.width, m_sSizeInPixel.height), MAX(m_sSizeInPixel.width, m_sSizeInPixel.height));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m_bNotHVGA)
|
|
||||||
{
|
|
||||||
s = CCSizeMake(MAX(m_sSizeInPoint.width, m_sSizeInPoint.height), MIN(m_sSizeInPoint.width, m_sSizeInPoint.height));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s = CCSizeMake(MAX(m_sSizeInPixel.width, m_sSizeInPixel.height), MIN(m_sSizeInPixel.width, m_sSizeInPixel.height));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CCRect CCEGLView::getFrame()
|
CCRect CCEGLView::getFrame()
|
||||||
|
@ -313,15 +263,11 @@ int CCEGLView::setDeviceOrientation(int eOritation)
|
||||||
{
|
{
|
||||||
if (m_bNotHVGA)
|
if (m_bNotHVGA)
|
||||||
{
|
{
|
||||||
m_sSizeInPoint.width = 480;
|
|
||||||
m_sSizeInPoint.height = 800;
|
|
||||||
m_sSizeInPixel.width = 480;
|
m_sSizeInPixel.width = 480;
|
||||||
m_sSizeInPixel.height = 800;
|
m_sSizeInPixel.height = 800;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sSizeInPoint.width = 320;
|
|
||||||
m_sSizeInPoint.height = 480;
|
|
||||||
m_sSizeInPixel.width = 320;
|
m_sSizeInPixel.width = 320;
|
||||||
m_sSizeInPixel.height = 480;
|
m_sSizeInPixel.height = 480;
|
||||||
}
|
}
|
||||||
|
@ -330,25 +276,32 @@ int CCEGLView::setDeviceOrientation(int eOritation)
|
||||||
{
|
{
|
||||||
if (m_bNotHVGA)
|
if (m_bNotHVGA)
|
||||||
{
|
{
|
||||||
m_sSizeInPoint.width = 800;
|
|
||||||
m_sSizeInPoint.height = 480;
|
|
||||||
m_sSizeInPixel.width = 800;
|
m_sSizeInPixel.width = 800;
|
||||||
m_sSizeInPixel.height = 480;
|
m_sSizeInPixel.height = 480;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sSizeInPoint.width = 480;
|
|
||||||
m_sSizeInPoint.height = 320;
|
|
||||||
m_sSizeInPixel.width = 480;
|
m_sSizeInPixel.width = 480;
|
||||||
m_sSizeInPixel.height = 320;
|
m_sSizeInPixel.height = 320;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate the factor and the rect of viewport
|
||||||
|
m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width,
|
||||||
|
(float)m_sSizeInPixel.height / m_sSizeInPoint.height);
|
||||||
|
int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor);
|
||||||
|
int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor);
|
||||||
|
m_rcViewPort.origin.x = (m_sSizeInPixel.width - viewPortW) / 2;
|
||||||
|
m_rcViewPort.origin.y = (m_sSizeInPixel.height - viewPortH) / 2;
|
||||||
|
m_rcViewPort.size.width = viewPortW;
|
||||||
|
m_rcViewPort.size.height = viewPortH;
|
||||||
|
|
||||||
return m_eInitOrientation;
|
return m_eInitOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
|
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
|
||||||
{
|
{
|
||||||
if (m_bNotHVGA)
|
// if (m_bNotHVGA)
|
||||||
{
|
{
|
||||||
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
||||||
glViewport((GLint)(x * factor) + m_rcViewPort.origin.x,
|
glViewport((GLint)(x * factor) + m_rcViewPort.origin.x,
|
||||||
|
@ -356,18 +309,18 @@ void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
|
||||||
(GLint)(w * factor),
|
(GLint)(w * factor),
|
||||||
(GLint)(h * factor));
|
(GLint)(h * factor));
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
glViewport((GLint)x,
|
// glViewport((GLint)x,
|
||||||
(GLint)y,
|
// (GLint)y,
|
||||||
(GLint)w,
|
// (GLint)w,
|
||||||
(GLint)h);
|
// (GLint)h);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
|
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
|
||||||
{
|
{
|
||||||
if (m_bNotHVGA)
|
// if (m_bNotHVGA)
|
||||||
{
|
{
|
||||||
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
|
||||||
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
|
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
|
||||||
|
@ -375,23 +328,23 @@ void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
|
||||||
(GLint)(w * factor),
|
(GLint)(w * factor),
|
||||||
(GLint)(h * factor));
|
(GLint)(h * factor));
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
glScissor((GLint)x,
|
// glScissor((GLint)x,
|
||||||
(GLint)y,
|
// (GLint)y,
|
||||||
(GLint)w,
|
// (GLint)w,
|
||||||
(GLint)h);
|
// (GLint)h);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCEGLView::setIMEKeyboardState(bool /*bOpen*/)
|
void CCEGLView::setIMEKeyboardState(bool bOpen)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//bada
|
bool CCEGLView::Create(Osp::App::Application* pApp, int width, int height)
|
||||||
bool
|
|
||||||
CCEGLView::Create(Osp::App::Application* pApp)
|
|
||||||
{
|
{
|
||||||
|
m_sSizeInPoint.width = width;
|
||||||
|
m_sSizeInPoint.height = height;
|
||||||
// Construct an XML form
|
// Construct an XML form
|
||||||
Construct(FORM_STYLE_NORMAL);
|
Construct(FORM_STYLE_NORMAL);
|
||||||
Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
|
Frame *pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();
|
||||||
|
@ -423,16 +376,12 @@ CCEGLView::OnInitializing(void)
|
||||||
|| (rc.width == 720 && rc.height == 480))
|
|| (rc.width == 720 && rc.height == 480))
|
||||||
{
|
{
|
||||||
m_bNotHVGA = false;
|
m_bNotHVGA = false;
|
||||||
m_sSizeInPoint.width = 320;
|
|
||||||
m_sSizeInPoint.height = 480;
|
|
||||||
m_sSizeInPixel.width = 320;
|
m_sSizeInPixel.width = 320;
|
||||||
m_sSizeInPixel.height = 480;
|
m_sSizeInPixel.height = 480;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_bNotHVGA = true;
|
m_bNotHVGA = true;
|
||||||
m_sSizeInPoint.width = 480;
|
|
||||||
m_sSizeInPoint.height = 800;
|
|
||||||
m_sSizeInPixel.width = 480;
|
m_sSizeInPixel.width = 480;
|
||||||
m_sSizeInPixel.height = 800;
|
m_sSizeInPixel.height = 800;
|
||||||
}
|
}
|
||||||
|
@ -452,8 +401,7 @@ CCEGLView::OnInitializing(void)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result CCEGLView::OnTerminating(void)
|
||||||
CCEGLView::OnTerminating(void)
|
|
||||||
{
|
{
|
||||||
result r = E_SUCCESS;
|
result r = E_SUCCESS;
|
||||||
|
|
||||||
|
@ -472,19 +420,22 @@ void CCEGLView::OnTouchIndicated(const Osp::Ui::Control& source,
|
||||||
void CCEGLView::OnTouchPressed(const Osp::Ui::Control& source,
|
void CCEGLView::OnTouchPressed(const Osp::Ui::Control& source,
|
||||||
const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo)
|
const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo)
|
||||||
{
|
{
|
||||||
AppLog("OnTouchPressed... x = %d, y = %d", currentPosition.x, currentPosition.y);
|
float x, y;
|
||||||
|
if (!m_bNotHVGA)
|
||||||
|
{
|
||||||
|
x = currentPosition.x * 2 / 3;
|
||||||
|
y = currentPosition.y * 2 / 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = currentPosition.x;
|
||||||
|
y = currentPosition.y;
|
||||||
|
}
|
||||||
|
AppLog("OnTouchPressed... x = %f, y = %f", x, y);
|
||||||
if (m_pDelegate && m_pTouch)
|
if (m_pDelegate && m_pTouch)
|
||||||
{
|
{
|
||||||
m_bCaptured = true;
|
m_bCaptured = true;
|
||||||
if (m_bNotHVGA)
|
m_pTouch->SetTouchInfo(0, (x - m_rcViewPort.origin.x) / m_fScreenScaleFactor, (y - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
|
||||||
{
|
|
||||||
m_pTouch->SetTouchInfo(0, (float)currentPosition.x, (float)currentPosition.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pTouch->SetTouchInfo(0, (float)currentPosition.x*2/3, (float)currentPosition.y*2/3);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pSet->addObject(m_pTouch);
|
m_pSet->addObject(m_pTouch);
|
||||||
m_pDelegate->touchesBegan(m_pSet, NULL);
|
m_pDelegate->touchesBegan(m_pSet, NULL);
|
||||||
}
|
}
|
||||||
|
@ -503,18 +454,22 @@ void CCEGLView::OnTouchLongPressed(const Osp::Ui::Control& source,
|
||||||
void CCEGLView::OnTouchReleased(const Osp::Ui::Control& source,
|
void CCEGLView::OnTouchReleased(const Osp::Ui::Control& source,
|
||||||
const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo)
|
const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo)
|
||||||
{
|
{
|
||||||
AppLog("OnTouchReleased... x = %d, y = %d", currentPosition.x, currentPosition.y);
|
float x, y;
|
||||||
|
if (!m_bNotHVGA)
|
||||||
|
{
|
||||||
|
x = currentPosition.x * 2 / 3;
|
||||||
|
y = currentPosition.y * 2 / 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = currentPosition.x;
|
||||||
|
y = currentPosition.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppLog("OnTouchReleased... x = %f, y = %f", x, y);
|
||||||
if (m_bCaptured)
|
if (m_bCaptured)
|
||||||
{
|
{
|
||||||
if (m_bNotHVGA)
|
m_pTouch->SetTouchInfo(0, (x - m_rcViewPort.origin.x) / m_fScreenScaleFactor, (y - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
|
||||||
{
|
|
||||||
m_pTouch->SetTouchInfo(0, (float)currentPosition.x, (float)currentPosition.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pTouch->SetTouchInfo(0, (float)currentPosition.x*2/3, (float)currentPosition.y*2/3);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pDelegate->touchesEnded(m_pSet, NULL);
|
m_pDelegate->touchesEnded(m_pSet, NULL);
|
||||||
m_pSet->removeObject(m_pTouch);
|
m_pSet->removeObject(m_pTouch);
|
||||||
m_bCaptured = false;
|
m_bCaptured = false;
|
||||||
|
@ -525,17 +480,21 @@ void CCEGLView::OnTouchReleased(const Osp::Ui::Control& source,
|
||||||
void CCEGLView::OnTouchMoved(const Osp::Ui::Control& source,
|
void CCEGLView::OnTouchMoved(const Osp::Ui::Control& source,
|
||||||
const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo)
|
const Osp::Graphics::Point& currentPosition, const Osp::Ui::TouchEventInfo & touchInfo)
|
||||||
{
|
{
|
||||||
AppLog("OnTouchMoved... x = %d, y = %d", currentPosition.x, currentPosition.y);
|
float x, y;
|
||||||
|
if (!m_bNotHVGA)
|
||||||
|
{
|
||||||
|
x = currentPosition.x * 2 / 3;
|
||||||
|
y = currentPosition.y * 2 / 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = currentPosition.x;
|
||||||
|
y = currentPosition.y;
|
||||||
|
}
|
||||||
|
AppLog("OnTouchMoved... x = %f, y = %f", x, y);
|
||||||
if (m_bCaptured)
|
if (m_bCaptured)
|
||||||
{
|
{
|
||||||
if (m_bNotHVGA)
|
m_pTouch->SetTouchInfo(0, (x - m_rcViewPort.origin.x) / m_fScreenScaleFactor, (y - m_rcViewPort.origin.y) / m_fScreenScaleFactor);
|
||||||
{
|
|
||||||
m_pTouch->SetTouchInfo(0, (float)currentPosition.x, (float)currentPosition.y);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pTouch->SetTouchInfo(0, (float)currentPosition.x*2/3, (float)currentPosition.y*2/3);
|
|
||||||
}
|
|
||||||
m_pDelegate->touchesMoved(m_pSet, NULL);
|
m_pDelegate->touchesMoved(m_pSet, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static CCEGLView& sharedOpenGLView();
|
static CCEGLView& sharedOpenGLView();
|
||||||
|
|
||||||
//bada
|
/*
|
||||||
bool Create(Osp::App::Application* pApp);
|
* param
|
||||||
|
* width[in]: resource width
|
||||||
|
* height[in]: resource height
|
||||||
|
*/
|
||||||
|
bool Create(Osp::App::Application* pApp, int width, int height);
|
||||||
virtual result OnInitializing(void);
|
virtual result OnInitializing(void);
|
||||||
virtual result OnTerminating(void);
|
virtual result OnTerminating(void);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ bool AppDelegate::initInstance()
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA)
|
||||||
|
|
||||||
CCEGLView * pMainWnd = new CCEGLView();
|
CCEGLView * pMainWnd = new CCEGLView();
|
||||||
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this));
|
CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this, 480, 320));
|
||||||
CCFileUtils::setResourcePath("/Res/");
|
CCFileUtils::setResourcePath("/Res/");
|
||||||
|
|
||||||
#endif // CC_PLATFORM_BADA
|
#endif // CC_PLATFORM_BADA
|
||||||
|
|
Loading…
Reference in New Issue