美文网首页Cocos2d-X与游戏开发cocos2d-Luacocos2d
cocos2d-x lua 获取精灵移动的距离

cocos2d-x lua 获取精灵移动的距离

作者: 亮亮同学 | 来源:发表于2017-12-18 15:58 被阅读18次

cocos2d-x技术群新群:117871561
c++技术交流群:593010226

--点击开始获取位置

function cardLayer:ontochBegan(touch,event)
local pos = touch:getLocation()
self.beganPos = pos
end
--移动时获取开始位置和移动后位置的距离
function cardLayer:ontouchMoved(touch,event)
local pos  = touch:getLocation()
--获取移动的距离
local distance = cc.pGetDistance(pos,self.beganPos)
end

相关文章

网友评论

    本文标题:cocos2d-x lua 获取精灵移动的距离

    本文链接:https://www.haomeiwen.com/subject/zatpwxtx.html