cocos2d-x-3.x

how to place a sprite at touch position


I follow the lecture of this website: website My code is same as first part of the website.But the position where the label placed in is uppon the place I clicked at. Could anybody help me?


Solution

  • wrong code is at

    bool AppDelegate::applicationDidFinishLaunching() {
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("Hello World");
        glview->setFrameSize(640, 480);
        director->setOpenGLView(glview);
    }
    
    auto scene = HelloWorld::createScene();
    director->runWithScene(scene);
    
    return true;
    }
    

    the code line;

    glview->setFrameSize(640, 480);
    

    setFrameSizw width diffrent size of defalut window size;