mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1143 from walzer/gles20
fixed #1413, add CCTouch::getLocation(), getDelta() method
This commit is contained in:
commit
b0e440dca1
|
@ -125,7 +125,8 @@ tilemap_parallax_nodes/CCTMXTiledMap.cpp \
|
||||||
tilemap_parallax_nodes/CCTMXXMLParser.cpp \
|
tilemap_parallax_nodes/CCTMXXMLParser.cpp \
|
||||||
tilemap_parallax_nodes/CCTileMapAtlas.cpp \
|
tilemap_parallax_nodes/CCTileMapAtlas.cpp \
|
||||||
touch_dispatcher/CCTouchDispatcher.cpp \
|
touch_dispatcher/CCTouchDispatcher.cpp \
|
||||||
touch_dispatcher/CCTouchHandler.cpp
|
touch_dispatcher/CCTouchHandler.cpp \
|
||||||
|
touch_dispatcher/CCTouch.cpp
|
||||||
|
|
||||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
|
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \
|
||||||
$(LOCAL_PATH)/include \
|
$(LOCAL_PATH)/include \
|
||||||
|
|
|
@ -1094,14 +1094,12 @@ CCPoint CCNode::convertToWindowSpace(const CCPoint& nodePoint)
|
||||||
// convenience methods which take a CCTouch instead of CCPoint
|
// convenience methods which take a CCTouch instead of CCPoint
|
||||||
CCPoint CCNode::convertTouchToNodeSpace(CCTouch *touch)
|
CCPoint CCNode::convertTouchToNodeSpace(CCTouch *touch)
|
||||||
{
|
{
|
||||||
CCPoint point = touch->locationInView();
|
CCPoint point = touch->getLocation();
|
||||||
point = CCDirector::sharedDirector()->convertToGL(point);
|
|
||||||
return this->convertToNodeSpace(point);
|
return this->convertToNodeSpace(point);
|
||||||
}
|
}
|
||||||
CCPoint CCNode::convertTouchToNodeSpaceAR(CCTouch *touch)
|
CCPoint CCNode::convertTouchToNodeSpaceAR(CCTouch *touch)
|
||||||
{
|
{
|
||||||
CCPoint point = touch->locationInView();
|
CCPoint point = touch->getLocation();
|
||||||
point = CCDirector::sharedDirector()->convertToGL(point);
|
|
||||||
return this->convertToNodeSpaceAR(point);
|
return this->convertToNodeSpaceAR(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -645,8 +645,7 @@ const ccColor3B& CCMenu::getColor(void)
|
||||||
|
|
||||||
CCMenuItem* CCMenu::itemForTouch(CCTouch *touch)
|
CCMenuItem* CCMenu::itemForTouch(CCTouch *touch)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
|
|
||||||
|
|
||||||
if (m_pChildren && m_pChildren->count() > 0)
|
if (m_pChildren && m_pChildren->count() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
52e0e6423f79bb3dcac84c3c6333a9df1a461cb9
|
9269aad72103fe898f626bacd11c9719e4914743
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="9.00"
|
Version="9.00"
|
||||||
|
@ -1002,7 +1002,11 @@
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="touch_dispatcher"
|
Name="touch_dispatcher"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath="..\touch_dispatcher\CCTouch.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\touch_dispatcher\CCTouch.h"
|
RelativePath="..\touch_dispatcher\CCTouch.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
@ -210,7 +210,8 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXLayer.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXLayer.cpp" />
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXObjectGroup.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXObjectGroup.cpp" />
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXTiledMap.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXTiledMap.cpp" />
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXXMLParser.cpp" />
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXXMLParser.cpp" />
|
||||||
|
<ClCompile Include="..\touch_dispatcher\CCTouch.cpp" />
|
||||||
<ClCompile Include="..\touch_dispatcher\CCTouchDispatcher.cpp" />
|
<ClCompile Include="..\touch_dispatcher\CCTouchDispatcher.cpp" />
|
||||||
<ClCompile Include="..\touch_dispatcher\CCTouchHandler.cpp" />
|
<ClCompile Include="..\touch_dispatcher\CCTouchHandler.cpp" />
|
||||||
<ClCompile Include="..\keypad_dispatcher\CCKeypadDelegate.cpp" />
|
<ClCompile Include="..\keypad_dispatcher\CCKeypadDelegate.cpp" />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="base_nodes">
|
<Filter Include="base_nodes">
|
||||||
|
@ -345,6 +345,9 @@
|
||||||
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXXMLParser.cpp">
|
<ClCompile Include="..\tileMap_parallax_nodes\CCTMXXMLParser.cpp">
|
||||||
<Filter>tilemap_parallax_nodes</Filter>
|
<Filter>tilemap_parallax_nodes</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\touch_dispatcher\CCTouch.cpp">
|
||||||
|
<Filter>touch_dispatcher</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="..\touch_dispatcher\CCTouchDispatcher.cpp">
|
<ClCompile Include="..\touch_dispatcher\CCTouchDispatcher.cpp">
|
||||||
<Filter>touch_dispatcher</Filter>
|
<Filter>touch_dispatcher</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/****************************************************************************
|
||||||
|
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.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "support/CCPointExtension.h"
|
||||||
|
#include "CCTouch.h"
|
||||||
|
#include "CCDirector.h"
|
||||||
|
|
||||||
|
NS_CC_BEGIN
|
||||||
|
|
||||||
|
// returns the current touch location in screen coordinates
|
||||||
|
CCPoint CCTouch::getLocationInView() const
|
||||||
|
{
|
||||||
|
return m_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the current previous location in screen coordinates
|
||||||
|
CCPoint CCTouch::getPreviousLocationInView() const
|
||||||
|
{
|
||||||
|
return m_prevPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the current touch location in OpenGL coordinates
|
||||||
|
CCPoint CCTouch::getLocation() const
|
||||||
|
{
|
||||||
|
return CCDirector::sharedDirector()->convertToGL(m_point);
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the previous touch location in OpenGL coordinates
|
||||||
|
CCPoint CCTouch::getPreviousLocation() const
|
||||||
|
{
|
||||||
|
return CCDirector::sharedDirector()->convertToGL(m_prevPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// returns the delta position between the current location and the previous location in OpenGL coordinates
|
||||||
|
CCPoint CCTouch::getDelta() const
|
||||||
|
{
|
||||||
|
return ccpSub(getLocation(), getPreviousLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_CC_END
|
|
@ -42,9 +42,29 @@ public:
|
||||||
: m_nId(0)
|
: m_nId(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CCPoint locationInView() { return m_point; }
|
/** returns the current touch location in OpenGL coordinates */
|
||||||
CCPoint previousLocationInView() { return m_prevPoint; }
|
CCPoint getLocation() const;
|
||||||
|
/** returns the previous touch location in OpenGL coordinates */
|
||||||
|
CCPoint getPreviousLocation() const;
|
||||||
|
/** returns the current touch location in screen coordinates */
|
||||||
|
CCPoint getDelta() const;
|
||||||
|
/** returns the current touch location in screen coordinates */
|
||||||
|
CCPoint getLocationInView() const;
|
||||||
|
/** returns the previous touch location in screen coordinates */
|
||||||
|
CCPoint getPreviousLocationInView() const;
|
||||||
|
|
||||||
|
/** returns the current touch location in screen coordinates
|
||||||
|
@deprecated: use CCTouch::getLocationInView() instead.
|
||||||
|
CCTouch::getLocation() is recommended, it will return OpenGL coordinate.
|
||||||
|
*/
|
||||||
|
CC_DEPRECATED_ATTRIBUTE CCPoint locationInView() { return m_point; }
|
||||||
|
|
||||||
|
/** returns the current previous location in screen coordinates
|
||||||
|
@deprecated: use CCTouch::getPreviousLocationInView() instead.
|
||||||
|
CCTouch::getPreviousLocation() is recommended, it will return OpenGL coordinate.
|
||||||
|
*/
|
||||||
|
CC_DEPRECATED_ATTRIBUTE CCPoint previousLocationInView() { return m_prevPoint; }
|
||||||
|
|
||||||
void setTouchInfo(int id, float x, float y)
|
void setTouchInfo(int id, float x, float y)
|
||||||
{
|
{
|
||||||
m_nId = id;
|
m_nId = id;
|
||||||
|
|
|
@ -272,9 +272,8 @@ bool CCControl::isOpacityModifyRGB()
|
||||||
|
|
||||||
CCPoint CCControl::getTouchLocation(CCTouch* touch)
|
CCPoint CCControl::getTouchLocation(CCTouch* touch)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation=touch->locationInView();; // Get the touch position
|
CCPoint touchLocation = touch->getLocation();; // Get the touch position
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation); // Convert the position to GL space
|
touchLocation = this->getParent()->convertToNodeSpace(touchLocation); // Convert to the node space of this class
|
||||||
touchLocation = this->getParent()->convertToNodeSpace(touchLocation); // Convert to the node space of this class
|
|
||||||
|
|
||||||
return touchLocation;
|
return touchLocation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,9 +165,8 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite*
|
||||||
//this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control
|
//this is the same as CCControl::getTouchLocation, but it returns the position relative to the position of this control
|
||||||
CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch)
|
CCPoint CCControlSlider::getTouchLocationInControl(CCTouch* touch)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation=touch->locationInView();; // Get the touch position
|
CCPoint touchLocation = touch->getLocation();; // Get the touch position
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation); // Convert the position to GL space
|
touchLocation = convertToNodeSpace(touchLocation); // Convert to the node space of this class
|
||||||
touchLocation = convertToNodeSpace(touchLocation); // Convert to the node space of this class
|
|
||||||
|
|
||||||
if (touchLocation.x < 0)
|
if (touchLocation.x < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -373,8 +373,7 @@ void CCControlSwitch::setEnabled(bool enabled)
|
||||||
|
|
||||||
CCPoint CCControlSwitch::locationFromTouch(CCTouch* pTouch)
|
CCPoint CCControlSwitch::locationFromTouch(CCTouch* pTouch)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = pTouch->locationInView(); // Get the touch position
|
CCPoint touchLocation = pTouch->getLocation(); // Get the touch position
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation); // Convert the position to GL space
|
|
||||||
touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class
|
touchLocation = this->convertToNodeSpace(touchLocation); // Convert to the node space of this class
|
||||||
|
|
||||||
return touchLocation;
|
return touchLocation;
|
||||||
|
|
|
@ -265,9 +265,7 @@ void Box2DTestLayer::ccTouchesEnded(CCSet* touches, CCEvent* event)
|
||||||
if(!touch)
|
if(!touch)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
|
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
|
|
||||||
addNewSpriteAtPosition( location );
|
addNewSpriteAtPosition( location );
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,14 +138,7 @@ bool MenuLayer::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void MenuLayer::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
void MenuLayer::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint diff = touch->getDelta();
|
||||||
CCPoint prevLocation = touch->previousLocationInView();
|
|
||||||
|
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
prevLocation = CCDirector::sharedDirector()->convertToGL( prevLocation );
|
|
||||||
|
|
||||||
CCPoint diff = ccpSub(touchLocation,prevLocation);
|
|
||||||
|
|
||||||
CCNode *node = getChildByTag( kTagBox2DNode );
|
CCNode *node = getChildByTag( kTagBox2DNode );
|
||||||
CCPoint currentPos = node->getPosition();
|
CCPoint currentPos = node->getPosition();
|
||||||
node->setPosition( ccpAdd(currentPos, diff) );
|
node->setPosition( ccpAdd(currentPos, diff) );
|
||||||
|
@ -221,8 +214,7 @@ void Box2DView::registerWithTouchDispatcher()
|
||||||
|
|
||||||
bool Box2DView::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
bool Box2DView::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
|
|
||||||
CCPoint nodePosition = convertToNodeSpace( touchLocation );
|
CCPoint nodePosition = convertToNodeSpace( touchLocation );
|
||||||
// NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);
|
// NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);
|
||||||
|
@ -232,8 +224,7 @@ bool Box2DView::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void Box2DView::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
void Box2DView::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
CCPoint nodePosition = convertToNodeSpace( touchLocation );
|
CCPoint nodePosition = convertToNodeSpace( touchLocation );
|
||||||
|
|
||||||
m_test->MouseMove(b2Vec2(nodePosition.x,nodePosition.y));
|
m_test->MouseMove(b2Vec2(nodePosition.x,nodePosition.y));
|
||||||
|
@ -241,8 +232,7 @@ void Box2DView::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void Box2DView::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
void Box2DView::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
CCPoint nodePosition = convertToNodeSpace( touchLocation );
|
CCPoint nodePosition = convertToNodeSpace( touchLocation );
|
||||||
|
|
||||||
m_test->MouseUp(b2Vec2(nodePosition.x,nodePosition.y));
|
m_test->MouseUp(b2Vec2(nodePosition.x,nodePosition.y));
|
||||||
|
|
|
@ -111,8 +111,7 @@ void BugsTestMainLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
m_tBeginPos = touch->locationInView();
|
m_tBeginPos = touch->getLocation();
|
||||||
m_tBeginPos = CCDirector::sharedDirector()->convertToGL( m_tBeginPos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BugsTestMainLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
void BugsTestMainLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
|
@ -120,8 +119,7 @@ void BugsTestMainLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
float nMoveY = touchLocation.y - m_tBeginPos.y;
|
float nMoveY = touchLocation.y - m_tBeginPos.y;
|
||||||
|
|
||||||
CCPoint curPos = m_pItmeMenu->getPosition();
|
CCPoint curPos = m_pItmeMenu->getPosition();
|
||||||
|
|
|
@ -239,9 +239,7 @@ void ChipmunkAccelTouchTestLayer::ccTouchesEnded(CCSet* touches, CCEvent* event)
|
||||||
if(!touch)
|
if(!touch)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
|
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
|
|
||||||
addNewSpriteAtPosition( location );
|
addNewSpriteAtPosition( location );
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,14 +42,13 @@ void MainLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
CCPoint convertedLocation = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
|
|
||||||
CCNode* s = getChildByTag(kTagSprite);
|
CCNode* s = getChildByTag(kTagSprite);
|
||||||
s->stopAllActions();
|
s->stopAllActions();
|
||||||
s->runAction( CCMoveTo::create(1, CCPointMake(convertedLocation.x, convertedLocation.y) ) );
|
s->runAction( CCMoveTo::create(1, CCPointMake(location.x, location.y) ) );
|
||||||
float o = convertedLocation.x - s->getPosition().x;
|
float o = location.x - s->getPosition().x;
|
||||||
float a = convertedLocation.y - s->getPosition().y;
|
float a = location.y - s->getPosition().y;
|
||||||
float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) );
|
float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) );
|
||||||
|
|
||||||
if( a < 0 )
|
if( a < 0 )
|
||||||
|
|
|
@ -191,8 +191,7 @@ void CocosDenshionTest::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
m_tBeginPos = touch->locationInView();
|
m_tBeginPos = touch->getLocation();
|
||||||
m_tBeginPos = CCDirector::sharedDirector()->convertToGL( m_tBeginPos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CocosDenshionTest::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
void CocosDenshionTest::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
|
@ -200,8 +199,7 @@ void CocosDenshionTest::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
float nMoveY = touchLocation.y - m_tBeginPos.y;
|
float nMoveY = touchLocation.y - m_tBeginPos.y;
|
||||||
|
|
||||||
CCPoint curPos = m_pItmeMenu->getPosition();
|
CCPoint curPos = m_pItmeMenu->getPosition();
|
||||||
|
|
|
@ -1289,7 +1289,7 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::CCObject *sender)
|
||||||
void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
|
void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
|
||||||
{
|
{
|
||||||
CCTouch *touch = (CCTouch *)pTouches->anyObject();
|
CCTouch *touch = (CCTouch *)pTouches->anyObject();
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocationInView();
|
||||||
|
|
||||||
if (CCRect::CCRectContainsPoint(this->m_pArrowsShouldRetain->boundingBox(), location))
|
if (CCRect::CCRectContainsPoint(this->m_pArrowsShouldRetain->boundingBox(), location))
|
||||||
{
|
{
|
||||||
|
@ -1314,7 +1314,7 @@ void BitmapFontMultiLineAlignment::ccTouchesMoved(cocos2d::CCSet *pTouches, coco
|
||||||
}
|
}
|
||||||
|
|
||||||
CCTouch *touch = (CCTouch *)pTouches->anyObject();
|
CCTouch *touch = (CCTouch *)pTouches->anyObject();
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocationInView();
|
||||||
|
|
||||||
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
|
|
|
@ -181,8 +181,7 @@ void LayerTest1::updateSize(CCPoint &touchLocation)
|
||||||
|
|
||||||
bool LayerTest1::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
bool LayerTest1::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
|
|
||||||
|
|
||||||
updateSize(touchLocation);
|
updateSize(touchLocation);
|
||||||
|
|
||||||
|
@ -191,16 +190,14 @@ bool LayerTest1::ccTouchBegan(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void LayerTest1::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
void LayerTest1::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
|
|
||||||
|
|
||||||
updateSize(touchLocation);
|
updateSize(touchLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerTest1::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
void LayerTest1::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL(touchLocation);
|
|
||||||
|
|
||||||
updateSize(touchLocation);
|
updateSize(touchLocation);
|
||||||
}
|
}
|
||||||
|
@ -334,8 +331,7 @@ void LayerGradient::ccTouchesMoved(CCSet * touches, CCEvent *event)
|
||||||
|
|
||||||
CCSetIterator it = touches->begin();
|
CCSetIterator it = touches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
CCPoint start = touch->locationInView();
|
CCPoint start = touch->getLocation();
|
||||||
start = CCDirector::sharedDirector()->convertToGL(start);
|
|
||||||
|
|
||||||
CCPoint diff = ccpSub( ccp(s.width/2,s.height/2), start);
|
CCPoint diff = ccpSub( ccp(s.width/2,s.height/2), start);
|
||||||
diff = ccpNormalize(diff);
|
diff = ccpNormalize(diff);
|
||||||
|
|
|
@ -95,8 +95,7 @@ void MotionStreakTest2::ccTouchesMoved(CCSet* touches, CCEvent* event)
|
||||||
CCSetIterator it = touches->begin();
|
CCSetIterator it = touches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
|
|
||||||
streak->setPosition( touchLocation );
|
streak->setPosition( touchLocation );
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,7 @@ void MutiTouchTestLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
|
||||||
{
|
{
|
||||||
CCTouch* pTouch = (CCTouch*)(*iter);
|
CCTouch* pTouch = (CCTouch*)(*iter);
|
||||||
TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this);
|
TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this);
|
||||||
CCPoint location = pTouch->locationInView();
|
CCPoint location = pTouch->getLocation();
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
|
|
||||||
pTouchPoint->setTouchPos(location);
|
pTouchPoint->setTouchPos(location);
|
||||||
pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]);
|
pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]);
|
||||||
|
@ -96,8 +95,7 @@ void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
{
|
{
|
||||||
CCTouch* pTouch = (CCTouch*)(*iter);
|
CCTouch* pTouch = (CCTouch*)(*iter);
|
||||||
TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
|
TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
|
||||||
CCPoint location = pTouch->locationInView();
|
CCPoint location = pTouch->getLocation();
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
pTP->setTouchPos(location);
|
pTP->setTouchPos(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -800,9 +800,7 @@ void ConvertToNode::ccTouchesEnded(CCSet* touches, CCEvent *event)
|
||||||
for( CCSetIterator it = touches->begin(); it != touches->end(); ++it)
|
for( CCSetIterator it = touches->begin(); it != touches->end(); ++it)
|
||||||
{
|
{
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
|
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
|
|
||||||
for( int i = 0; i < 3; i++)
|
for( int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,13 +153,7 @@ void Parallax2::ccTouchCancelled(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void Parallax2::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
void Parallax2::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint diff = touch->getDelta();
|
||||||
CCPoint prevLocation = touch->previousLocationInView();
|
|
||||||
|
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
prevLocation = CCDirector::sharedDirector()->convertToGL( prevLocation );
|
|
||||||
|
|
||||||
CCPoint diff = ccpSub(touchLocation,prevLocation);
|
|
||||||
|
|
||||||
CCNode* node = getChildByTag(kTagNode);
|
CCNode* node = getChildByTag(kTagNode);
|
||||||
CCPoint currentPos = node->getPosition();
|
CCPoint currentPos = node->getPosition();
|
||||||
|
|
|
@ -1155,8 +1155,7 @@ void ParticleDemo::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void ParticleDemo::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
void ParticleDemo::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
CCPoint convertedLocation = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
|
|
||||||
CCPoint pos = CCPointZero;
|
CCPoint pos = CCPointZero;
|
||||||
if (m_background)
|
if (m_background)
|
||||||
|
@ -1166,7 +1165,7 @@ void ParticleDemo::ccTouchEnded(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
if (m_emitter != NULL)
|
if (m_emitter != NULL)
|
||||||
{
|
{
|
||||||
m_emitter->setPosition( ccpSub(convertedLocation, pos) );
|
m_emitter->setPosition( ccpSub(location, pos) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,10 +210,8 @@ RenderTextureSave::~RenderTextureSave()
|
||||||
void RenderTextureSave::ccTouchesMoved(CCSet* touches, CCEvent* event)
|
void RenderTextureSave::ccTouchesMoved(CCSet* touches, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCTouch *touch = (CCTouch *)touches->anyObject();
|
CCTouch *touch = (CCTouch *)touches->anyObject();
|
||||||
CCPoint start = touch->locationInView();
|
CCPoint start = touch->getLocation();
|
||||||
start = CCDirector::sharedDirector()->convertToGL(start);
|
CCPoint end = touch->getPreviousLocation();
|
||||||
CCPoint end = touch->previousLocationInView();
|
|
||||||
end = CCDirector::sharedDirector()->convertToGL(end);
|
|
||||||
|
|
||||||
// begin drawing to the render texture
|
// begin drawing to the render texture
|
||||||
m_pTarget->begin();
|
m_pTarget->begin();
|
||||||
|
@ -401,9 +399,8 @@ void RenderTextureZbuffer::ccTouchesBegan(cocos2d::CCSet *touches, cocos2d::CCEv
|
||||||
for (iter = touches->begin(); iter != touches->end(); ++iter)
|
for (iter = touches->begin(); iter != touches->end(); ++iter)
|
||||||
{
|
{
|
||||||
touch = (CCTouch *)(*iter);
|
touch = (CCTouch *)(*iter);
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
|
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
sp1->setPosition(location);
|
sp1->setPosition(location);
|
||||||
sp2->setPosition(location);
|
sp2->setPosition(location);
|
||||||
sp3->setPosition(location);
|
sp3->setPosition(location);
|
||||||
|
@ -423,9 +420,8 @@ void RenderTextureZbuffer::ccTouchesMoved(CCSet* touches, CCEvent* event)
|
||||||
for (iter = touches->begin(); iter != touches->end(); ++iter)
|
for (iter = touches->begin(); iter != touches->end(); ++iter)
|
||||||
{
|
{
|
||||||
touch = (CCTouch *)(*iter);
|
touch = (CCTouch *)(*iter);
|
||||||
CCPoint location = touch->locationInView();
|
CCPoint location = touch->getLocation();
|
||||||
|
|
||||||
location = CCDirector::sharedDirector()->convertToGL(location);
|
|
||||||
sp1->setPosition(location);
|
sp1->setPosition(location);
|
||||||
sp2->setPosition(location);
|
sp2->setPosition(location);
|
||||||
sp3->setPosition(location);
|
sp3->setPosition(location);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
5fc56349b3bc725b72183e738c2673d084631809
|
50af410e677a3b1b7d5fd6f2725dfd200284bc78
|
|
@ -204,8 +204,7 @@ void KeyboardNotificationLayer::keyboardWillShow(CCIMEKeyboardNotificationInfo&
|
||||||
bool KeyboardNotificationLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
|
bool KeyboardNotificationLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
|
||||||
{
|
{
|
||||||
CCLOG("++++++++++++++++++++++++++++++++++++++++++++");
|
CCLOG("++++++++++++++++++++++++++++++++++++++++++++");
|
||||||
m_beginPos = pTouch->locationInView();
|
m_beginPos = pTouch->getLocation();
|
||||||
m_beginPos = CCDirector::sharedDirector()->convertToGL(m_beginPos);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,8 +215,7 @@ void KeyboardNotificationLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CCPoint endPos = pTouch->locationInView();
|
CCPoint endPos = pTouch->getLocation();
|
||||||
endPos = CCDirector::sharedDirector()->convertToGL(endPos);
|
|
||||||
|
|
||||||
float delta = 5.0f;
|
float delta = 5.0f;
|
||||||
if (::abs(endPos.x - m_beginPos.x) > delta
|
if (::abs(endPos.x - m_beginPos.x) > delta
|
||||||
|
|
|
@ -1533,14 +1533,7 @@ void TileDemo::ccTouchCancelled(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
void TileDemo::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
void TileDemo::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
{
|
{
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint diff = touch->getDelta();
|
||||||
CCPoint prevLocation = touch->previousLocationInView();
|
|
||||||
|
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
prevLocation = CCDirector::sharedDirector()->convertToGL( prevLocation );
|
|
||||||
|
|
||||||
CCPoint diff = ccpSub(touchLocation, prevLocation);
|
|
||||||
|
|
||||||
CCNode *node = getChildByTag(kTagTileMap);
|
CCNode *node = getChildByTag(kTagTileMap);
|
||||||
CCPoint currentPos = node->getPosition();
|
CCPoint currentPos = node->getPosition();
|
||||||
node->setPosition( ccpAdd(currentPos, diff) );
|
node->setPosition( ccpAdd(currentPos, diff) );
|
||||||
|
|
|
@ -72,8 +72,7 @@ void Paddle::ccTouchMoved(CCTouch* touch, CCEvent* event)
|
||||||
|
|
||||||
CCAssert(m_state == kPaddleStateGrabbed, L"Paddle - Unexpected state!");
|
CCAssert(m_state == kPaddleStateGrabbed, L"Paddle - Unexpected state!");
|
||||||
|
|
||||||
CCPoint touchPoint = touch->locationInView();
|
CCPoint touchPoint = touch->getLocation();
|
||||||
touchPoint = CCDirector::sharedDirector()->convertToGL( touchPoint );
|
|
||||||
|
|
||||||
setPosition( CCPointMake(touchPoint.x, getPosition().y) );
|
setPosition( CCPointMake(touchPoint.x, getPosition().y) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,8 +197,7 @@ void TestController::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
m_tBeginPos = touch->locationInView();
|
m_tBeginPos = touch->getLocation();
|
||||||
m_tBeginPos = CCDirector::sharedDirector()->convertToGL( m_tBeginPos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestController::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
void TestController::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
|
@ -206,8 +205,7 @@ void TestController::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
|
||||||
CCSetIterator it = pTouches->begin();
|
CCSetIterator it = pTouches->begin();
|
||||||
CCTouch* touch = (CCTouch*)(*it);
|
CCTouch* touch = (CCTouch*)(*it);
|
||||||
|
|
||||||
CCPoint touchLocation = touch->locationInView();
|
CCPoint touchLocation = touch->getLocation();
|
||||||
touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
|
|
||||||
float nMoveY = touchLocation.y - m_tBeginPos.y;
|
float nMoveY = touchLocation.y - m_tBeginPos.y;
|
||||||
|
|
||||||
CCPoint curPos = m_pItemMenu->getPosition();
|
CCPoint curPos = m_pItemMenu->getPosition();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
60d4aa8ea9ce2c7754e7e64dcfd910fb8e7cffc1
|
c62c8fc39eb5a5c0b9dde4f0cffa9815d032699b
|
Loading…
Reference in New Issue