2、影响缩放
3、影响旋转
#include "T01LayerAnchorPoint.h" CCScene * T01LayerAnchorPoint::scene() { CCScene * scene = CCScene::create(); T01LayerAnchorPoint * layer = T01LayerAnchorPoint::create(); scene->addChild(layer); return scene; } bool T01LayerAnchorPoint::init() { if (!CCLayer::init()) { return false; } winSize = CCDirector::sharedDirector()->getWinSize(); sprite = CCSprite::create("anchor3.png"); //sprite->setScale(4);//放大4倍 //sprite->setAnchorPoint(ccp(0.8,0.2));//设置锚点位置 sprite->ignoreAnchorPointForPosition(true);//设置位置忽略锚点 sprite->setPosition(ccp(winSize.width / 2,winSize.height / 2)); this->addChild(sprite); //定时器 schedule(schedule_selector(T01LayerAnchorPoint::rotationBy2s),0.3); return true; } void T01LayerAnchorPoint::draw()//绘制 { ccDrawColor4B(255,255); ccDrawLine(ccp(0,winSize.height / 2),ccp(winSize.width,winSize.height / 2,0)); ccDrawLine(ccp(winSize.width / 2,0),ccp(winSize.width / 2,winSize.height)); } void T01LayerAnchorPoint::rotationBy2s(float dt) { static float num = 0; num += 30; sprite->setRotation(num);//旋转 }
#ifndef __T01LayerAnchorPoint_H__ #define __T01LayerAnchorPoint_H__ #include "cocos2d.h" USING_NS_CC; class T01LayerAnchorPoint : public CCLayer { public: static CCScene *scene(); CREATE_FUNC(T01LayerAnchorPoint); bool init(); void draw(); CCSize winSize; CCSprite * sprite; void rotationBy2s(float dt); }; #endif
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。