本文整理汇总了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;
}
示例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;
}
示例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;
}