PuzzleSDK
UIS9ChangeAnchorPoint类 参考

#include <UIScale9SpriteTest.h>

+ 类 UIS9ChangeAnchorPoint 继承关系图:
+ UIS9ChangeAnchorPoint 的协作图:

Public 成员函数

 CREATE_FUNC (UIS9ChangeAnchorPoint)
 
virtual bool init () override
 
- Public 成员函数 继承自 UIScene
 UIScene ()
 
 ~UIScene ()
 
virtual void onEnter () override
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string title () const
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 
- Protected 属性 继承自 UIScene
cocos2d::Layer * _uiLayer
 
cocos2d::ui::Layout * _widget
 
cocos2d::ui::Text * _sceneTitle
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

详细描述

在文件 UIScale9SpriteTest.h267 行定义.

成员函数说明

◆ CREATE_FUNC()

UIS9ChangeAnchorPoint::CREATE_FUNC ( UIS9ChangeAnchorPoint  )

◆ init()

bool UIS9ChangeAnchorPoint::init ( )
overridevirtual

重载 UIScene .

在文件 UIScale9SpriteTest.cpp867 行定义.

868{
869 if (UIScene::init()) {
870 SpriteFrameCache::getInstance()->addSpriteFramesWithFile(s_s9s_blocks9_plist);
871
872 auto winSize = Director::getInstance()->getWinSize();
873 float x = winSize.width / 2;
874 float y = 0 + (winSize.height / 2 + 50);
875
876
877 auto normalSprite = ui::Scale9Sprite::createWithSpriteFrameName("blocks9r.png");
878 normalSprite->setPosition(Vec2(x, y ));
879// normalSprite->setScale9Enabled(false);
880// normalSprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT);
881
882 this->addChild(normalSprite);
883
884
885 Button* button1 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
886 button1->setPosition(Vec2(winSize.width/2 - 100,winSize.height/2 - 50));
887 button1->setName("button2");
888 button1->setTitleText("Vec(0,0)");
889 button1->addTouchEventListener([=](Ref*, Widget::TouchEventType type)
890 {
891 if (type == Widget::TouchEventType::ENDED) {
892 normalSprite->setAnchorPoint(Vec2::ZERO);
893 normalSprite->setScale9Enabled(true);
894 CCLOG("position = %f, %f, anchor point = %f, %f", normalSprite->getPosition().x,
895 normalSprite->getPosition().y,
896 normalSprite->getAnchorPoint().x,
897 normalSprite->getAnchorPoint().y);
898 CCLOG("tests:content size : width = %f, height = %f",
899 normalSprite->getContentSize().width,
900 normalSprite->getContentSize().height);
901 }
902 });
903 this->addChild(button1);
904
905 Button* button2 = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
906 button2->setPosition(Vec2(winSize.width/2 + 100,winSize.height/2 - 50));
907 button2->setName("button2");
908 button2->setTitleText("Vec(1,1)");
909 button2->addTouchEventListener([=](Ref*, Widget::TouchEventType type)
910 {
911 if (type == Widget::TouchEventType::ENDED) {
912 normalSprite->setAnchorPoint(Vec2::ANCHOR_TOP_RIGHT);
913 normalSprite->setScale9Enabled(false);
914 CCLOG("position = %f, %f, anchor point = %f, %f", normalSprite->getPosition().x,
915 normalSprite->getPosition().y,
916 normalSprite->getAnchorPoint().x,
917 normalSprite->getAnchorPoint().y);
918 CCLOG("tests:content size : width = %f, height = %f",
919 normalSprite->getContentSize().width,
920 normalSprite->getContentSize().height);
921
922 }
923 });
924 this->addChild(button2);
925
926
927 return true;
928 }
929 return false;
930}
virtual bool init() override
Definition: UIScene.cpp:46
static const char s_s9s_blocks9_plist[]
Definition: testResource.h:68

引用了 UIScene::init() , 以及 s_s9s_blocks9_plist.

+ 函数调用图:

该类的文档由以下文件生成: