Exemplo n.º 1
0
void CMirage::Init(CCLayer* a_pParentLayer, b2World* a_World, MirageData a_Data)
{
	auto wallSprite = CCSprite::create("map/map3/object/box_wall.png");
	wallSprite->setPosition(a_Data.m_vWallPosition);
	a_pParentLayer->addChild(wallSprite, OBJECT_ZORDER);
	
	m_pWallSprite = wallSprite;

	m_pBodySprite = shared_ptr<CBox2dSprite>(new CBox2dSprite);
	m_pBodySprite->Init(wallSprite, a_World, b2BodyType::b2_staticBody);

	CObjectManager::getInstance()->getBox2dSprite()->InsertObject(m_pBodySprite);

	m_pBody = m_pBodySprite->getBodyStructure().body;

	m_pGlassTexture = CTextureFactory::CreateTexture("map/map3/object/glass.png");

	m_pGlassCrashedTexture = CTextureFactory::CreateTexture("map/map3/object/glass_piece.png");

	m_pGlassSprite = CCSprite::createWithTexture(m_pGlassTexture);
	m_pGlassSprite->setPosition(a_Data.m_vGlassPosition);

	setBodyPositionTo(a_Data.m_vWallPosition);
	a_pParentLayer->addChild(m_pGlassSprite, OBJECT_ZORDER);

	m_pActionSprite = m_pGlassSprite;

	m_pBehavior = CreateBehavior();
}
Exemplo n.º 2
0
RESULT
BehaviorManager::Init( IN const string& settingsFilename )
{
    RETAILMSG(ZONE_INFO, "BehaviorManager::Init( %s )", settingsFilename.c_str());

    RESULT rval = S_OK;
    char   path[MAX_PATH];
    
    //
    // Create a Settings object and load the file.
    //
    Settings mySettings;
    if ( FAILED(mySettings.Read( settingsFilename )) )
    {
        RETAILMSG(ZONE_ERROR, "ERROR: BehaviorManager::Init( %s ): failed to load settings file", settingsFilename.c_str() );
        return E_UNEXPECTED;
    }
    

    //
    // Create each Behavior.
    //
    UINT32 numBehaviors = mySettings.GetInt("/Behaviors.NumBehaviors");

    for (int i = 0; i < numBehaviors; ++i)
    {
        sprintf(path, "/Behaviors/Behavior%d", i);
        //DEBUGMSG(ZONE_INFO, "Loading [%s]", path);

        Behavior *pBehavior = NULL;
        CreateBehavior( &mySettings, path, &pBehavior );
        if (!pBehavior)
        {
            RETAILMSG(ZONE_ERROR, "ERROR: BehaviorManager::Init( %s ): failed to create Behavior", path);
            // Continue loading other Behaviors rather than aborting.
            continue;
        }
        
        //DEBUGMSG(ZONE_Behavior, "Created Behavior [%s]", pBehavior->GetName().c_str());
        CHR(Add(pBehavior->GetName(), pBehavior));
    }
    
Exit:
    return rval;
}
Exemplo n.º 3
0
int LuaBhvCreateComposite(lua_State* _State, BhvCallback _Callback) {
	struct Behavior* _Bhv = NULL;
	int _Len = 0;
	int _ChildSz = 0;
	struct Behavior* _Child = NULL;

	luaL_checktype(_State, 1, LUA_TTABLE);
	_Len = lua_rawlen(_State, 1);
	_Bhv = CreateBehavior(NULL, NULL, _Len, _Callback);
		lua_pushnil(_State);
		while(lua_next(_State, -2) != 0) {
			if((_Child = LuaCheckClass(_State, -1, LOBJ_BEHAVIOR)) == NULL) {
				lua_pop(_State, 1);
				continue;
			}
			_Bhv->Children[_ChildSz++] = _Child;
			lua_pop(_State, 1);
		}
		LuaCtor(_State, _Bhv, LOBJ_BEHAVIOR);
		return 1;
}