bool LVL_Player::init() { if(!setCharacter(characterID, stateID)) return false; m_direction = data.direction; long posX = data.x + (data.w / 2) - (state_cur.width / 2); long posY = data.y = data.y + data.h - state_cur.height; setSize(state_cur.width, state_cur.height); setPos(posX, posY); phys_setup.max_vel_y = 12; m_animator.tickAnimation(0.0); m_isLocked = false; if(m_isLuaPlayer) { try { lua_onInit(); } catch(luabind::error &e) { m_scene->getLuaEngine()->postLateShutdownError(e); return false; } } m_isInited = true; _syncSection(); m_momentum.saveOld(); return true; }
void LVL_Npc::init() { if(_isInited) return; phys_setup.gravityAccel=ConfigManager::marker_npc.phs_gravity_accel; phys_setup.max_vel_y= ConfigManager::marker_npc.phs_max_fall_speed; transformTo_x(data.id); setPos(data.x, data.y); _syncSection(); if(isLuaNPC && !data.generator){ try{ lua_onInit(); } catch (luabind::error& e) { LvlSceneP::s->getLuaEngine()->postLateShutdownError(e); } } _isInited=true; LvlSceneP::s->layers.registerItem(data.layer, this); }