Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17098

setRotation() moves sprite?

$
0
0

@nichlaspro132 wrote:

Hi!

Whenever I set the rotation of some arrows that I made for controls they get moved to another position?
Here is my code:

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();
	auto rightNormal = Sprite::create("arrow.png");
	auto leftNormal = Sprite::create("arrow.png");
	auto downNormal = Sprite::create("arrow.png");
	auto upNormal = Sprite::create("arrow.png");
	leftNormal->setRotation(45);
	downNormal->setRotation(90);
	upNormal->setRotation(270);
	buttonRight = MenuItemSprite::create(rightNormal, NULL, CC_CALLBACK_1(MovePad::action, this, "Right"));
	buttonLeft = MenuItemSprite::create(leftNormal, NULL, CC_CALLBACK_1(MovePad::action, this, "Left"));
	buttonUp = MenuItemSprite::create(upNormal, NULL, CC_CALLBACK_1(MovePad::action, this, "Right"));
	buttonDown = MenuItemSprite::create(downNormal, NULL, CC_CALLBACK_1(MovePad::action, this, "Right"));
	buttonRight->setPosition(Vec2(visibleSize.width - 100, visibleSize.height - 100));
	buttonLeft->setPosition(Vec2(visibleSize.width - 100, visibleSize.height - 100));
	buttonUp->setPosition(Vec2(visibleSize.width - 100, visibleSize.height - 100));
	buttonDown->setPosition(Vec2(visibleSize.width - 100, visibleSize.height - 100));
	Menu* menu = Menu::create(buttonRight, buttonLeft, buttonUp, buttonDown, NULL);
	menu->setPosition(Point(0, 0));
	this->addChild(menu, 1);

result:

Why and what to do?
Thank you!

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 17098

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>