Saturday, September 17, 2022
HomeGame DevelopmentTips on how to resolve this query - C++

Tips on how to resolve this query – C++


After I use the next code, I can see the “node2” sprite after operating this system.

	node2 = Sprite::create("ty.png");
	node2->setPosition(Vec2(700, 600));
	this->addChild(node2,5);
	auto listener = EventListenerKeyboard::create();
	listener->onKeyPressed = [=](cocos2d::EventKeyboard::KeyCode keyCode, Occasion* occasion) {
		keys[keyCode] = true;
	};
	listener->onKeyReleased = [=](cocos2d::EventKeyboard::KeyCode keyCode, Occasion* occasion) {
		keys[keyCode] = false;
	};
	_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
	this->scheduleUpdate();

However after I add the next code. I can’t see the “node2” sprite after operating this system.

	auto s = Director::getInstance()->getWinSize();
	auto pFollow = Observe::create(node2, Rect(0, 0, s.width + 3840, s.top)); 
	node2->runAction(pFollow);

Why?


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments