#pragma once
#include "cocos2d.h";
class Action_1 : public cocos2d:: CCLayer
{
public:
Action_1();
~Action_1();
virtual bool init();
static cocos2d::CCScene *scene();
void callback();
CREATE_FUNC(Action_1);
};
#include "Action_1.h"
using namespace cocos2d;
Action_1::Action_1()
{
}
Action_1::~Action_1()
{
}
CCScene *Action_1::scene()
{
CCScene *scene = CCScene::create();
Action_1 *layer = Action_1::create();
scene->addChild(layer);
return scene;
}
bool Action_1::init()
{
//获取屏幕大小
CCSize size = CCDirector::sharedDirector()->getWinSize();
//定义精灵
CCSprite *sp = CCSprite::create("20160222150945.png");
sp->setPosition(ccp(size.width/2,size.height/2));
addChild(sp);
CCSprite *sp1 = CCSprite::create("20160222150945.png");
sp1->setPosition(ccp(size.width /2, size.height / 4));
addChild(sp1);
//关于x轴翻转
CCActionInstant *file = CCFlipX::create(true);
sp->runAction(file);
//关于Y轴翻转
CCActionInstant *fy = CCFlipY::create(true);
sp1->runAction(fy);
//指定位置
//CCPlace *pplace = CCPlace::create(ccp(size.width*0.2, size.height*0.2));
sp->runAction(CCPlace::create(ccp(size.width*0.2, size.height*0.2)));
sp->setVisible(false);
//设置不可见----------------注意:setVisible与CCToggleVisibility都是设置是否可见
sp->runAction(CCToggleVisibility::create());
return true;
}
void Action_1::callback()
{
}