문제

    HttpRequest* request = new HttpRequest();
    request->setUrl("http://just-make-this-request-failed.com");
    request->setRequestType(HttpRequest::Type::GET);
    request->setResponseCallback(this, httpresponse_selector(HttpClientTest::onHttpRequestCompleted));

This code is from the NetworkTest of cocos2d-x 3.0. I don't understand why I should pass Layer* to setResponseCallback? What if I want to send/get request/response without creating a single layer? Why shouldn't I be able to do that?

도움이 되었습니까?

해결책

Selector in obj-c is just the name of the method so in order to call it you need a reference to the object as well. The code calls it "httpresponse_selector" and cocos2d-x is reportedly modelled after obj-c so might be it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top