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


C++ KeyFrame::fileName方法代码示例

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


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

示例1: loadSound

Status SoundManager::loadSound(Layer* soundLayer, int frameNumber, QString strSoundFile)
{
    Q_ASSERT(soundLayer);
    if (soundLayer->type() != Layer::SOUND)
    {
        return Status::ERROR_INVALID_LAYER_TYPE;
    }

    if (frameNumber < 0)
    {
        return Status::ERROR_INVALID_FRAME_NUMBER;
    }

    if (!QFile::exists(strSoundFile))
    {
        return Status::FILE_NOT_FOUND;
    }

    KeyFrame* key = soundLayer->getKeyFrameAt(frameNumber);
    if (key == nullptr)
    {
        key = new SoundClip;
        soundLayer->addKeyFrame(frameNumber, key);
    }

    if (!key->fileName().isEmpty())
    {
        // file path should be empty.
        // we can only load a audio clip to an empty key! 
        return Status::FAIL;
    }

    QString strCopyFile = soundLayer->object()->copyFileToDataFolder(strSoundFile);
    Q_ASSERT(!strCopyFile.isEmpty());

    QString sOriginalName = QFileInfo(strSoundFile).fileName();

    SoundClip* soundClip = dynamic_cast<SoundClip*>(key);
    soundClip->init(strCopyFile);
    soundClip->setSoundClipName(sOriginalName);

    Status st = createMediaPlayer(soundClip);
    if (!st.ok())
    {
        delete soundClip;
        return st;
    }

    return Status::OK;
}
开发者ID:chchwy,项目名称:pencil2d,代码行数:50,代码来源:soundmanager.cpp

示例2: loadSound

Status SoundManager::loadSound( Layer* soundLayer, int frameNumber, QString strSoundFile )
{
    Q_ASSERT( soundLayer );
    if ( soundLayer->type() != Layer::SOUND )
    {
        return Status::ERROR_INVALID_LAYER_TYPE;
    }

    if ( frameNumber < 0 )
    {
        return Status::ERROR_INVALID_FRAME_NUMBER;
    }

    if ( !QFile::exists( strSoundFile ) )
    {
        return Status::FILE_NOT_FOUND;
    }
    
    KeyFrame* key = soundLayer->getKeyFrameAt( frameNumber );
    if ( key == nullptr )
    {
        key = new SoundClip;
    }
    
    if ( !key->fileName().isEmpty() )
    {
        return Status::FAIL;
    }
    
    SoundClip* soundClip = dynamic_cast< SoundClip* >( key );
    soundClip->init( strSoundFile );
    
    Status st = mSoundPlayer->addSound( soundClip );

    if ( !st.ok() )
    {
        delete soundClip;
        return st;
    }
    
    bool bAddOK = soundLayer->addKeyFrame( frameNumber, soundClip );
    if ( !bAddOK )
    {
        delete soundClip;
        return Status::FAIL;
    }

    return Status::OK;
}
开发者ID:CandyFace,项目名称:pencil,代码行数:49,代码来源:soundmanager.cpp

示例3: toJsonObject

QJsonObject AnimationToJson::toJsonObject(const KeyFrame &keyFrame)
{
    QJsonObject object;
    object.insert("fileName", QFileInfo(keyFrame.fileName()).fileName());
    object.insert("rect", toJsonObject(keyFrame.rect()));
//    qDebug() << keyFrame.rect() << toJsonObject(keyFrame.rect());
    object.insert("offset", toJsonObject(keyFrame.offset()));

    QJsonObject customPropertiesObject;
    const auto customProperties = keyFrame.customProperties();
    for(auto it = customProperties.begin(); it != customProperties.end(); ++it) {
        customPropertiesObject.insert(it.key(), it.value());
    }
    object.insert("customProperties", customPropertiesObject);

    QJsonArray hitBoxes;
    for (HitBox *hitBox : keyFrame.hitBoxes()) {
        hitBoxes.append(toJsonObject(*hitBox));
    }
    object.insert("hitBoxes", hitBoxes);
    return object;
}
开发者ID:skyrpex,项目名称:Jam-Editor,代码行数:22,代码来源:animationtojson.cpp


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