예제 #1
0
Node::Node(void)
: _rotationX(0.0f)
, _rotationY(0.0f)
, _scaleX(1.0f)
, _scaleY(1.0f)
, _vertexZ(0.0f)
, _position(Point::ZERO)
, _skewX(0.0f)
, _skewY(0.0f)
, _anchorPointInPoints(Point::ZERO)
, _anchorPoint(Point::ZERO)
, _contentSize(Size::ZERO)
, _additionalTransformDirty(false)
, _transformDirty(true)
, _inverseDirty(true)
// children (lazy allocs)
// lazy alloc
, _ZOrder(0)
, _parent(nullptr)
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
, _tag(Node::INVALID_TAG)
// userData is always inited as nil
, _userData(nullptr)
, _userObject(nullptr)
, _shaderProgram(nullptr)
, _orderOfArrival(0)
, _running(false)
, _visible(true)
, _ignoreAnchorPointForPosition(false)
, _reorderChildDirty(false)
, _isTransitionFinished(false)
, _updateScriptHandler(0)
, _componentContainer(nullptr)
#if CC_USE_PHYSICS
, _physicsBody(nullptr)
#endif
, _displayedOpacity(255)
, _realOpacity(255)
, _displayedColor(Color3B::WHITE)
, _realColor(Color3B::WHITE)
, _cascadeColorEnabled(false)
, _cascadeOpacityEnabled(false)
{
    // set default scheduler and actionManager
    Director *director = Director::getInstance();
    _actionManager = director->getActionManager();
    _actionManager->retain();
    _scheduler = director->getScheduler();
    _scheduler->retain();
    _eventDispatcher = director->getEventDispatcher();
    _eventDispatcher->retain();
    
    ScriptEngineProtocol* engine = ScriptEngineManager::getInstance()->getScriptEngine();
    _scriptType = engine != nullptr ? engine->getScriptType() : kScriptTypeNone;

    kmMat4Identity(&_transform);
    kmMat4Identity(&_inverse);
    kmMat4Identity(&_additionalTransform);
}
예제 #2
0
Console::Console()
: _listenfd(-1)
, _running(false)
, _endThread(false)
, _userCommands(nullptr)
, _maxUserCommands(0)
, _sendDebugStrings(false)
{
    // VS2012 doesn't support initializer list, so we create a new array and assign its elements to '_command'.
	Command commands[] = {     
        { "config", std::bind(&Console::commandConfig, this, std::placeholders::_1, std::placeholders::_2) },
        { "debug msg on", [&](int fd, const char* command) {
            _sendDebugStrings = true;
        } },
        { "debug msg off", [&](int fd, const char* command) {
            _sendDebugStrings = false;
        } },
        { "exit", std::bind(&Console::commandExit, this, std::placeholders::_1, std::placeholders::_2) },
        { "fileutils dump", std::bind(&Console::commandFileUtilsDump, this, std::placeholders::_1, std::placeholders::_2) },
        { "fps on", [](int fd, const char* command) {
            Director *dir = Director::getInstance();
            Scheduler *sched = dir->getScheduler();
            sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, true));
        } },
        { "fps off", [](int fd, const char* command) {
            Director *dir = Director::getInstance();
            Scheduler *sched = dir->getScheduler();
            sched->performFunctionInCocosThread( std::bind(&Director::setDisplayStats, dir, false));
        } },
        { "help", std::bind(&Console::commandHelp, this, std::placeholders::_1, std::placeholders::_2) },
        { "scene graph", std::bind(&Console::commandSceneGraph, this, std::placeholders::_1, std::placeholders::_2) },
        { "textures", std::bind(&Console::commandTextures, this, std::placeholders::_1, std::placeholders::_2) },
    };

    _maxCommands = sizeof(commands)/sizeof(commands[0]);
	for (int i = 0; i < _maxCommands; ++i)
	{
		_commands[i] = commands[i];
	}
}
예제 #3
0
Node::Node(void)
: _rotationX(0.0f)
, _rotationY(0.0f)
, _scaleX(1.0f)
, _scaleY(1.0f)
, _vertexZ(0.0f)
, _position(Point::ZERO)
, _skewX(0.0f)
, _skewY(0.0f)
, _anchorPointInPoints(Point::ZERO)
, _anchorPoint(Point::ZERO)
, _contentSize(Size::ZERO)
, _additionalTransform(AffineTransformMakeIdentity())
, _camera(NULL)
// children (lazy allocs)
// lazy alloc
, _grid(NULL)
, _ZOrder(0)
, _children(NULL)
, _parent(NULL)
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
, _tag(kNodeTagInvalid)
// userData is always inited as nil
, _userData(NULL)
, _userObject(NULL)
, _shaderProgram(NULL)
, _GLServerState(ccGLServerState(0))
, _orderOfArrival(0)
, _running(false)
, _transformDirty(true)
, _inverseDirty(true)
, _additionalTransformDirty(false)
, _visible(true)
, _ignoreAnchorPointForPosition(false)
, _reorderChildDirty(false)
, _isTransitionFinished(false)
, _updateScriptHandler(0)
, _componentContainer(NULL)
{
    // set default scheduler and actionManager
    Director *director = Director::getInstance();
    _actionManager = director->getActionManager();
    _actionManager->retain();
    _scheduler = director->getScheduler();
    _scheduler->retain();

    ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine();
    _scriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone;
    _componentContainer = new ComponentContainer(this);
}
예제 #4
0
void FGgameinit::copyFileUpdate(float dt)
{
    
//#ifdef GameNeedUpdate
    if(copyfileName.size()>0)
    {

        string tempName = copyfileName[copyfileName.size()-1];
        if( copyfileAndUnzip(tempName.c_str()))
        {
            copyfileName.pop_back();
        }
    }else if (copyfileName.size()==0)
    {
        FGgameSet::getInstance()->setIntegerForKey("luaIsCopy",1);
        FGgameSet::getInstance()->flush();
        
    }
//#else
//    FGgameSet::getInstance()->setIntegerForKey("luaIsCopy",1);
//    FGgameSet::getInstance()->flush();
//#endif
    
    
    int nowluaisCopy= FGgameSet::getInstance()->getIntegerForKey("luaIsCopy");
    //拷贝完成 开始其他初始化
    if(nowluaisCopy==1)
    {
        string nowGameVersion = FGUpdateModule::SharedIntance()->requestGameVersion();
        FGgameSet::getInstance()->setStringForKey("gameVersion",nowGameVersion);
        FGgameSet::getInstance()->flush();
//        log("WTF__gameversion写入_%s",nowGameVersion.c_str());
        
        Director *pDirector = Director::getInstance();
        Scheduler *pCcscheduler = pDirector->getScheduler();
        pCcscheduler->unschedule(schedule_selector(FGgameinit::copyFileUpdate), this);
    
        Function.clear();
        Function.push_back(callfunc_selector(FGgameinit::initImageResources));
        //Function.push_back(callfunc_selector(FGgameinit::initSounResources));
        pCcscheduler->schedule(schedule_selector(FGgameinit::initResourcesUpdate), this,0.001,false);
        
        //渲染特效
        FGgameinit::SharedIntance()->showEffect();
    }
    
}
예제 #5
0
void FGgameinit::initStartGameviewGeneral()
{
    //TDGameAnalytics
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    //TDCCTalkingDataGA::onStart("FAF47ACC72DD5FCC7D076347A1CEACE9", FGMarketGetMarketName(SHARED_MARKET_API->getMarketCid()));
//    if(SHARED_MARKET_API->getMarketCid()==100)
//    {
//        FGappcpaInit();
//        
//    }
#endif
    
    LabelTitle = Label::createWithSystemFont(NSLocalizedString("游戏初始化中...","游戏启动"), "Helvetica", 40);
    LabelTitle->setColor(Color3B::WHITE);
    LabelTitle->setPosition(Vec2 ( VisibleRect::center().x,100));
    
    
    CreateBgInit();
    
    globalScene->addChild(LabelTitle);
    
//    ShowGameVersion();
    
    //TODO 暂不拷贝lua
    /*
    int luaisCopy= FGgameSet::getInstance()->getIntegerForKey("luaIsCopy");
    copyfileName.clear();
    if(luaisCopy!=1)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        //        copyfileName.push_back("allLua.zip");
        copyfileName.push_back("floragameRes_android_1.zip");
#else
        
#ifdef GameNeedUpdate
        copyfileName.push_back("allLua.zip");
#endif
        
#endif
    }
     */
    
    Director *pDirector = Director::getInstance();
    Scheduler *pCcscheduler = pDirector->getScheduler();
    pCcscheduler->schedule(schedule_selector(FGgameinit::copyFileUpdate), this, 0.001, false);
}
예제 #6
0
파일: Hero.cpp 프로젝트: lmk378/ProtoType
Hero::Hero() :
_body(nullptr),
_eventListenerCustom(nullptr),
_velocity(0),
_maxVelocity(3),
_speed(0.72),
_gravity(0),
_jumpPower(7.0f),
_jumpHeight(0.0f),
_animeSwitch(false),
_state(NORMAL),
_prevState(NORMAL)
{
    Director* director = Director::getInstance();
    Scheduler *scheduler = director->getScheduler();
    scheduler->schedule(schedule_selector(Hero::update), this, 0, false);
}
예제 #7
0
void FGgameinit::initResourcesUpdate(float dt)
{
    if(Function.size()>0)
    {
        (this->*(Function[Function.size()-1]))();
        Function.pop_back();
    }else if (Function.size()==0)
    {
        
        Director *pDirector = Director::getInstance();
        Scheduler *pCcscheduler = pDirector->getScheduler();
        pCcscheduler->unschedule(schedule_selector(FGgameinit::initResourcesUpdate), this);
        LabelTitle->removeFromParentAndCleanup(true);
#ifdef GameNeedUpdate
        gotoUpdateView();
#else
//        FGLayerManager::getGlobalLayerManager()->resetUILayer();
        AppDelegate::startLoadLua();
#endif
        
    }
    
}