Last active
August 7, 2017 15:21
-
-
Save ahcox/7fa8f928aa8ec4515f036e3499a1aba8 to your computer and use it in GitHub Desktop.
Dump a Cocos2D-x Touch to an ostream like std::cerr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void dumpTouch(std::ostream& out, const cocos2d::Touch* touch) | |
{ | |
if(touch){ | |
const auto loc = touch->getLocation(); | |
const auto prev = touch->getPreviousLocation(); | |
const auto start = touch->getStartLocation(); | |
const auto delta = touch->getDelta(); | |
const auto id = touch->getID(); | |
const auto viewLoc = touch->getLocationInView(); | |
const auto viewPrev = touch->getPreviousLocationInView(); | |
const auto viewStart = touch->getStartLocationInView(); | |
//const auto x = touch->get(); | |
out << ", id: " << id; | |
out << ", loc: (" << loc.x << ", " << loc.y <<")"; | |
out << ", prev: (" << prev.x << ", " << prev.y <<")"; | |
out << ", start: (" << start.x << ", " << start.y <<")"; | |
out << ", delta: (" << delta.x << ", " << delta.y <<")"; | |
// View loc is y-down | |
out << ", view loc: (" << viewLoc.x << ", " << viewLoc.y <<")"; | |
out << ", view prev: (" << viewPrev.x << ", " << viewPrev.y <<")"; | |
out << ", view start: (" << viewStart.x << ", " << viewStart.y <<")."; | |
} | |
out << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment