Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ahcox
Last active August 7, 2017 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahcox/7fa8f928aa8ec4515f036e3499a1aba8 to your computer and use it in GitHub Desktop.
Save ahcox/7fa8f928aa8ec4515f036e3499a1aba8 to your computer and use it in GitHub Desktop.
Dump a Cocos2D-x Touch to an ostream like std::cerr
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