c++ - Mouse/Touch coordinates in cocos2d-x -
i'm trying xy coordinates click, or better yet mouse pointer is, can convert them char , display them on screen, , remember in hellolua throwing coordinates of clicks , movements while clicked touch movements console, thought maybe similar in cpp cctouch command getlocationinview();, , did. in init, declare
settouchenabled(true);
and i'm trying touch coordinates use
cctouch ptouch; ccpoint p = ptouch.getlocationinview(); p = ccdirector::shareddirector()->converttogl(p); float x = p.x; float y = p.y;
however it's not working i'd expect work. know how mouse/touch coordinates return accurately in cocos2d-x(cpp)?
edit : sorry should have clarified, i'm working on windows 7 desktop in visualstudio express environment, , want project cross platform. hellolua application in samples had mouse clicks throw touch event begins , ends coordinates console, though using mouse. why hoping similar in cpp, except have coordinates printed on screen. using code, static values x , y, wouldn't change no matter clicked.
try code:
bool pickcard::cctouchbegan(cctouch* touch, ccevent* event) { ccpoint touchlocation = touch->getlocationinview(); touchlocation = ccdirector::shareddirector()->converttogl( touchlocation ); touchlocation=converttonodespace(touchlocation); cclog(" touchlocation x=%f touchlocation y=%f",touchlocation.x,touchlocation.y); }
Comments
Post a Comment