当前位置: 首页>>代码示例>>C++>>正文


C++ THSoundEffects::playSound方法代码示例

本文整理汇总了C++中THSoundEffects::playSound方法的典型用法代码示例。如果您正苦于以下问题:C++ THSoundEffects::playSound方法的具体用法?C++ THSoundEffects::playSound怎么用?C++ THSoundEffects::playSound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THSoundEffects的用法示例。


在下文中一共展示了THSoundEffects::playSound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: l_soundfx_play

static int l_soundfx_play(lua_State *L)
{
    THSoundEffects *pEffects = luaT_testuserdata<THSoundEffects>(L);
    lua_settop(L, 5);
    lua_getfenv(L, 1);
    lua_pushliteral(L, "archive");
    lua_rawget(L, 6);
    THSoundArchive *pArchive = (THSoundArchive*)lua_touserdata(L, 7);
    if(pArchive == NULL)
    {
        return 0;
    }
    // l_soundarc_checkidx requires the archive at the bottom of the stack
    lua_replace(L, 1);
    size_t iIndex = l_soundarc_checkidx(L, 2, pArchive);
    if(iIndex == pArchive->getSoundCount())
        return 2;
    if(lua_isnil(L, 4))
    {
        pEffects->playSound(iIndex, luaL_checknumber(L, 3));
    }
    else
    {
        pEffects->playSoundAt(iIndex, luaL_checknumber(L, 3), luaL_checkint(L, 4), luaL_checkint(L, 5));
    }
    lua_pushboolean(L, 1);
    return 1;
}
开发者ID:Skyivories,项目名称:corsix-th,代码行数:28,代码来源:th_lua_sound.cpp

示例2: l_soundfx_play

static int l_soundfx_play(lua_State *L)
{
    THSoundEffects *pEffects = luaT_testuserdata<THSoundEffects>(L);
    lua_settop(L, 7);
    lua_getfenv(L, 1);
    lua_pushliteral(L, "archive");
    lua_rawget(L,8);
    THSoundArchive *pArchive = (THSoundArchive*)lua_touserdata(L, 9);
    if(pArchive == nullptr)
    {
        return 0;
    }
    // l_soundarc_checkidx requires the archive at the bottom of the stack
    lua_replace(L, 1);
    size_t iIndex = l_soundarc_checkidx(L, 2, pArchive);
    if(iIndex == pArchive->getSoundCount())
        return 2;
    if(lua_isnil(L, 4))
    {
        pEffects->playSound(iIndex, luaL_checknumber(L, 3));
    }
    else
    {
        pEffects->playSoundAt(iIndex, luaL_checknumber(L, 3), static_cast<int>(luaL_checkinteger(L, 4)), static_cast<int>(luaL_checkinteger(L, 5)));
    }
    //SDL SOUND_OVER Callback Timer:
    //6: unusedPlayedCallbackID
    if(!lua_isnil(L, 6))
    {
        //7: Callback delay
        int iPlayedCallbackDelay = 0; //ms
        if(!lua_isnil(L, 7))
            iPlayedCallbackDelay = static_cast<int>(luaL_checknumber(L, 7));

        if(m_iPlayedSoundCallbackIDsPointer == sizeof(m_a_iPlayedSoundCallbackIDs))
            m_iPlayedSoundCallbackIDsPointer = 0;

        m_a_iPlayedSoundCallbackIDs[m_iPlayedSoundCallbackIDsPointer] = static_cast<int>(luaL_checkinteger(L, 6));
        size_t interval = pArchive->getSoundDuration(iIndex) + iPlayedCallbackDelay;
        SDL_TimerID timersID = SDL_AddTimer(static_cast<Uint32>(interval),
                                            played_sound_callback,
                                            &(m_a_iPlayedSoundCallbackIDs[m_iPlayedSoundCallbackIDsPointer]));
        m_mapSoundTimers.insert(std::pair<int, SDL_TimerID>(m_a_iPlayedSoundCallbackIDs[m_iPlayedSoundCallbackIDsPointer], timersID));
        m_iPlayedSoundCallbackIDsPointer++;
    }

    lua_pushboolean(L, 1);
    return 1;
}
开发者ID:AntoineLemaire,项目名称:CorsixTH,代码行数:49,代码来源:th_lua_sound.cpp


注:本文中的THSoundEffects::playSound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。