Exemple #1
0
TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException)
{
    Vector<Dictionary> jsKeyframes;
    v8::Handle<v8::Object> keyframe1 = v8::Object::New(m_isolate);
    v8::Handle<v8::Object> keyframe2 = v8::Object::New(m_isolate);

    setV8ObjectPropertyAsString(keyframe1, "width", "100px");
    setV8ObjectPropertyAsString(keyframe1, "offset", "0");

    // Height property appears only in keyframe2
    setV8ObjectPropertyAsString(keyframe2, "height", "100px");
    setV8ObjectPropertyAsString(keyframe2, "width", "0px");
    setV8ObjectPropertyAsString(keyframe2, "offset", "1");

    jsKeyframes.append(Dictionary(keyframe1, m_isolate));
    jsKeyframes.append(Dictionary(keyframe2, m_isolate));

    createAnimation(element.get(), jsKeyframes, 0, exceptionState);

    EXPECT_TRUE(exceptionState.hadException());
    EXPECT_EQ(NotSupportedError, exceptionState.code());
}
Exemple #2
0
Animation* AnimationTarget::createAnimationFromTo(const char* id, int propertyId, float* from, float* to, Curve::InterpolationType type, unsigned long duration)
{
    GP_ASSERT(from);
    GP_ASSERT(to);

    const unsigned int propertyComponentCount = getAnimationPropertyComponentCount(propertyId);
    GP_ASSERT(propertyComponentCount > 0);
    float* keyValues = new float[2 * propertyComponentCount];

    memcpy(keyValues, from, sizeof(float) * propertyComponentCount);
    memcpy(keyValues + propertyComponentCount, to, sizeof(float) * propertyComponentCount);

    unsigned int* keyTimes = new unsigned int[2];
    keyTimes[0] = 0;
    keyTimes[1] = (unsigned int)duration;

    Animation* animation = createAnimation(id, propertyId, 2, keyTimes, keyValues, type);

    SAFE_DELETE_ARRAY(keyValues);
    SAFE_DELETE_ARRAY(keyTimes);

    return animation;
}
Exemple #3
0
TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration)
{
    Vector<Dictionary, 0> jsKeyframes;
    v8::Handle<v8::Object> timingInput = v8::Object::New(m_isolate);
    Dictionary timingInputDictionary = Dictionary(v8::Handle<v8::Value>::Cast(timingInput), m_isolate);
    RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);

    RefPtrWillBeRawPtr<AnimationNodeTiming> specified = animation->timing();

    Nullable<double> numberDuration;
    String stringDuration;
    specified->getDuration("duration", numberDuration, stringDuration);
    EXPECT_TRUE(numberDuration.isNull());
    EXPECT_FALSE(stringDuration.isNull());
    EXPECT_EQ("auto", stringDuration);

    specified->setDuration("duration", 2.5);
    Nullable<double> numberDuration2;
    String stringDuration2;
    specified->getDuration("duration", numberDuration2, stringDuration2);
    EXPECT_FALSE(numberDuration2.isNull());
    EXPECT_EQ(2.5, numberDuration2.get());
    EXPECT_TRUE(stringDuration2.isNull());
}
Exemple #4
0
void BalloonTip::init()
{
  setWindowFlags(  Qt::FramelessWindowHint | Qt::ToolTip );
  setAttribute( Qt::WA_TranslucentBackground, true );

  createAnimation();
  createRects();
  defineArrowPosition();

  setArrowPosition( my_arrowPos );
  setFixedSize( my_popupRect.width() + 60, my_popupRect.height() + 60 );
  connect( my_closeButton, SIGNAL(clicked()), this, SLOT(close()) );

  if ( parentWidget() != 0 ) {
    parentWidget()->installEventFilter( this );
    QWidget* w = parentWidget()->parentWidget();
    while ( w != 0  ) {
      w->installEventFilter( this );
      w = w->parentWidget();
    }
  }

  setFixedSize( my_popupRect.size() + QSize( 60, 60 ) );
}
Exemple #5
0
void OutsideEnemy::move()
{
    if(mActionStatus == ENEMY_ACTION_STATUS_MOVE)
        return;
    
    CCPoint fromPos = OutsideEnemy::PathBegin2;
    CCPoint toPos = OutsideEnemy::PathEnd2;
    int posNum = 10;
    float dxFrom = (OutsideEnemy::PathBegin1.x - OutsideEnemy::PathBegin2.x) / posNum;
    float dyFrom = (OutsideEnemy::PathBegin1.y - OutsideEnemy::PathBegin2.y) / posNum;
    float dxTo = (OutsideEnemy::PathEnd1.x - OutsideEnemy::PathEnd2.x) / posNum;
    float dyTo = (OutsideEnemy::PathEnd1.y - OutsideEnemy::PathEnd2.y) / posNum;
    int xRandomIndex = (rand() % posNum);
    int YRandomIndex = (rand() % posNum);
    /*
    if(randomIndex == 0)
    {
        fromPos = OutsideEnemy::PathBegin;
        toPos = OutsideEnemy::PathEnd;
    }
    if(randomIndex == 1)
    {
        fromPos = OutsideEnemy::PathBegin1;
        toPos = OutsideEnemy::PathEnd1;
    }
    */
    fromPos.x = fromPos.x + dxFrom * xRandomIndex;
    fromPos.y = fromPos.y + dyFrom * YRandomIndex;
    toPos.x = toPos.x + dxTo * xRandomIndex;
    toPos.y = toPos.y + dyTo * YRandomIndex;
    CCPoint gap = ccpSub(fromPos, toPos);
    mFromPos = fromPos;
    mToPos = toPos;
    
    float len = ccpLength(gap);
    float useTime = len / mMoveSpeed;//len/120.0;
    CCSequence* sc = nullptr;
    CCSpawn * arrowAction = nullptr;
    Action* action = nullptr;
    if(useTime != 0)
    {
        //sc = CCSequence::create(CCMoveTo::create(useTime, onePos),CCCallFunc::create(this, callfunc_selector(Walker::moveOnePoint)),NULL);
        //sc = CCSequence::create(CCMoveTo::create(useTime, toPos), CCCallFunc::create(this, callfunc_selector(OutsideEnemy::die)), NULL);
        sc = CCSequence::create(CCMoveTo::create(useTime, toPos), CCCallFunc::create(this, callfunc_selector(OutsideEnemy::scare)), NULL);
        CCSequence *arrowSc = CCSequence::create(CCDelayTime::create(useTime - 0.25), CCCallFunc::create(this, callfunc_selector(OutsideEnemy::shootArrow)), NULL);
        arrowAction = CCSpawn::create(sc, arrowSc, NULL);
        action = createAnimation(ENEMY_ACTION_STATUS_MOVE);
    }
    //Action* action = createAnimation();
    mIconSpr->setPosition(fromPos);
    if (action)
    {
        auto sp = Spawn::create(arrowAction, action, NULL);
        mIconSpr->stopAllActions();
        mIconSpr->runAction(sp);
    }
    else
    {
        mIconSpr->stopAllActions();
        mIconSpr->runAction(arrowAction);
    }

    mActionStatus = ENEMY_ACTION_STATUS_MOVE;
}
TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto)
{
    Vector<Dictionary, 0> jsKeyframes;
    RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState);
    EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
}
void AppConfig::initAnimations()
{
	createAnimation(COIN_ANIMATE_NAME,COIN_ANIMATE_FORMAT,1,36);
	createAnimation(USERPLANE_DEATH_ANIMATE_NAME,USERPLANE_DEATH_ANIMATE_FORMAT,1,13);
	createAnimation(ENEMYPLANE_DEATH_ANIMATE_NAME,ENEMYPLANE_DEATH_ANIMATE_FORMAT,1,12);
}
Exemple #8
0
Animation* AnimationTarget::createAnimation(const char* id, Properties* animationProperties)
{
    GP_ASSERT(animationProperties);
    if (std::strcmp(animationProperties->getNamespace(), "animation") != 0)
    {
        GP_ERROR("Invalid animation namespace '%s'.", animationProperties->getNamespace());
        return NULL;
    }

    const char* propertyIdStr = animationProperties->getString("property");
    if (propertyIdStr == NULL)
    {
        GP_ERROR("Attribute 'property' must be specified for an animation.");
        return NULL;
    }

    // Get animation target property id
	int propertyId = getPropertyId(_targetType, propertyIdStr);
    if (propertyId == -1)
    {
        GP_ERROR("Property ID is invalid.");
        return NULL;
    }

    unsigned int keyCount = animationProperties->getInt("keyCount");
    if (keyCount == 0)
    {
        GP_ERROR("Attribute 'keyCount' must be specified for an animation.");
        return NULL;
    }

    const char* keyTimesStr = animationProperties->getString("keyTimes");
    if (keyTimesStr == NULL)
    {
        GP_ERROR("Attribute 'keyTimes' must be specified for an animation.");
        return NULL;
    }

    const char* keyValuesStr = animationProperties->getString("keyValues");
    if (keyValuesStr == NULL)
    {
        GP_ERROR("Attribute 'keyValues' must be specified for an animation.");
        return NULL;
    }

    const char* curveStr = animationProperties->getString("curve");
    if (curveStr == NULL)
    {
        GP_ERROR("Attribute 'curve' must be specified for an animation.");
        return NULL;
    }

    char delimeter = ' ';
    size_t startOffset = 0;
    size_t endOffset = std::string::npos;

    unsigned int* keyTimes = new unsigned int[keyCount];
    for (size_t i = 0; i < keyCount; i++)
    {
        endOffset = static_cast<std::string>(keyTimesStr).find_first_of(delimeter, startOffset);
        if (endOffset != std::string::npos)
        {
            keyTimes[i] = std::strtoul(static_cast<std::string>(keyTimesStr).substr(startOffset, endOffset - startOffset).c_str(), NULL, 0);
        }
        else
        {
            keyTimes[i] = std::strtoul(static_cast<std::string>(keyTimesStr).substr(startOffset, static_cast<std::string>(keyTimesStr).length()).c_str(), NULL, 0);
        }
        startOffset = endOffset + 1;
    }

    startOffset = 0;
    endOffset = std::string::npos;

    int componentCount = getAnimationPropertyComponentCount(propertyId);
    GP_ASSERT(componentCount > 0);

    unsigned int components = keyCount * componentCount;

    float* keyValues = new float[components];
    for (unsigned int i = 0; i < components; i++)
    {
        endOffset = static_cast<std::string>(keyValuesStr).find_first_of(delimeter, startOffset);
        if (endOffset != std::string::npos)
        {
            keyValues[i] = std::atof(static_cast<std::string>(keyValuesStr).substr(startOffset, endOffset - startOffset).c_str());
        }
        else
        {
            keyValues[i] = std::atof(static_cast<std::string>(keyValuesStr).substr(startOffset, static_cast<std::string>(keyValuesStr).length()).c_str());
        }
        startOffset = endOffset + 1;
    }

    const char* keyInStr = animationProperties->getString("keyIn");
    float* keyIn = NULL;
    if (keyInStr)
    {
        keyIn = new float[components];
        startOffset = 0;
        endOffset = std::string::npos;
        for (unsigned int i = 0; i < components; i++)
        {
            endOffset = static_cast<std::string>(keyInStr).find_first_of(delimeter, startOffset);
            if (endOffset != std::string::npos)
            {
                keyIn[i] = std::atof(static_cast<std::string>(keyInStr).substr(startOffset, endOffset - startOffset).c_str());
            }
            else
            {
                keyIn[i] = std::atof(static_cast<std::string>(keyInStr).substr(startOffset, static_cast<std::string>(keyInStr).length()).c_str());
            }
            startOffset = endOffset + 1;
        }
    }

    const char* keyOutStr = animationProperties->getString("keyOut");
    float* keyOut = NULL;
    if (keyOutStr)
    {
        keyOut = new float[components];
        startOffset = 0;
        endOffset = std::string::npos;
        for (unsigned int i = 0; i < components; i++)
        {
            endOffset = static_cast<std::string>(keyOutStr).find_first_of(delimeter, startOffset);
            if (endOffset != std::string::npos)
            {
                keyOut[i] = std::atof(static_cast<std::string>(keyOutStr).substr(startOffset, endOffset - startOffset).c_str());
            }
            else
            {
                keyOut[i] = std::atof(static_cast<std::string>(keyOutStr).substr(startOffset, static_cast<std::string>(keyOutStr).length()).c_str());
            }
            startOffset = endOffset + 1;
        }
    }

    int curve = Curve::getInterpolationType(curveStr);

    Animation* animation = NULL;
    if (keyIn && keyOut)
    {
        animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, keyIn, keyOut, (Curve::InterpolationType)curve);
    }
    else
    {
        animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
    }

    const char* repeat = animationProperties->getString("repeatCount");
    if (repeat)
    {
        if (strcmp(repeat, ANIMATION_TARGET_INDEFINITE_STR) == 0)
        {
            animation->getClip()->setRepeatCount(AnimationClip::REPEAT_INDEFINITE);
        }
        else
        {
            float value;
            sscanf(repeat, "%f", &value);
            animation->getClip()->setRepeatCount(value);
        }
    }
    
    SAFE_DELETE_ARRAY(keyOut);
    SAFE_DELETE_ARRAY(keyIn);
    SAFE_DELETE_ARRAY(keyValues);
    SAFE_DELETE_ARRAY(keyTimes);

    Properties* pClip = animationProperties->getNextNamespace();
    if (pClip && std::strcmp(pClip->getNamespace(), "clip") == 0)
    {
        int frameCount = animationProperties->getInt("frameCount");
        if (frameCount <= 0)
        {
            GP_ERROR("Frame count must be greater than zero for a clip.");
            return animation;
        }
        animation->createClips(animationProperties, (unsigned int) frameCount);
    }
    
    return animation;
}
Exemple #9
0
void Walker::moveOnePoint(float tab){
    if(m_movePositions.size()>m_moveIndex){
        mCurrentSeq = mTargetSeq;
        mTargetSeq = m_moveSeqs[m_moveIndex];
        CCPoint onePos = m_movePositions[m_moveIndex];
        CCPoint lastPos = m_point;
        if(m_moveIndex!=0){
            lastPos = m_movePositions[m_moveIndex-1];
        }
        
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_CHECK_ZORDER, this);
        m_lastDirect = getDirection(lastPos,onePos);
        if(m_moveIndex != 0)
        {
            this->changeDirect(m_lastDirect);
        }
        m_status = WALKER_ACTION_MOVE;
        m_loopTimes = numeric_limits<int>::max();
        
        this->unschedule(schedule_selector(Walker::playAttack));
        if (m_armType == 1 || m_armType == 4 || m_armType == 3 || m_armType == 7)
        {
            this->schedule(schedule_selector(Walker::playAttack), 2);
            playAttack(0);
        }
        
        CCPoint gap = ccpSub(lastPos, onePos);
        float len = ccpLength(gap);
        float useTime = len/m_moveSpd;//len/120.0;
        CCSequence* sc = nullptr;
        Action* action = nullptr;
        if(useTime == 0)
        {
            sc = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Walker::moveOnePoint)),NULL);
        }
        else
        {
            sc = CCSequence::create(CCMoveTo::create(useTime, onePos),CCCallFunc::create(this, callfunc_selector(Walker::moveOnePoint)),NULL);
            action = createAnimation();
        }
        //Action* action = createAnimation();
        if (action)
        {
            auto sp = Spawn::create(sc, action, NULL);
            m_iconSpr->runAction(sp);
        }
        else
        {
            m_iconSpr->runAction(sc);
        }
        m_moveIndex += 1;
        
    }else{
        /*
        m_status = WALKER_ACTION_STAND;
        this->changeDirect(m_lastDirect,true);
        CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(MSG_SOLDIER_STOP, this);
        */
        onMoveFinished();
    }
}
Exemple #10
0
void KPrView::initActions()
{
    if ( !kopaDocument()->isReadWrite() )
       setXMLFile( "kpresenter_readonly.rc" );
    else
       setXMLFile( "kpresenter.rc" );

    // do special kpresenter stuff here
    m_actionExportHtml = new KAction(i18n("Export as HTML..."), this);
    actionCollection()->addAction("file_export_html", m_actionExportHtml);
    connect(m_actionExportHtml, SIGNAL(triggered()), this, SLOT(exportToHtml()));

    m_actionViewModeNormal = new KAction(i18n("Normal"), this);
    m_actionViewModeNormal->setCheckable(true);
    m_actionViewModeNormal->setChecked(true);
    actionCollection()->addAction("view_normal", m_actionViewModeNormal);
    connect(m_actionViewModeNormal, SIGNAL(triggered()), this, SLOT(showNormal()));

    m_actionViewModeNotes = new KAction(i18n("Notes"), this);
    m_actionViewModeNotes->setCheckable(true);
    actionCollection()->addAction("view_notes", m_actionViewModeNotes);
    connect(m_actionViewModeNotes, SIGNAL(triggered()), this, SLOT(showNotes()));

    m_actionViewModeSlidesSorter = new KAction(i18n("Slides Sorter"), this);
    m_actionViewModeSlidesSorter->setCheckable(true);
    actionCollection()->addAction("view_slides_sorter", m_actionViewModeSlidesSorter);
    connect(m_actionViewModeSlidesSorter, SIGNAL(triggered()), this, SLOT(showSlidesSorter()));

    m_actionInsertPictures = new KAction(i18n("Insert Pictures..."), this);
    actionCollection()->addAction("insert_pictures", m_actionInsertPictures);
    connect(m_actionInsertPictures, SIGNAL(activated()), this, SLOT(insertPictures()));

    QActionGroup *viewModesGroup = new QActionGroup(this);
    viewModesGroup->addAction(m_actionViewModeNormal);
    viewModesGroup->addAction(m_actionViewModeNotes);
    viewModesGroup->addAction(m_actionViewModeSlidesSorter);

    m_actionCreateAnimation = new KAction( i18n( "Create Appear Animation" ), this );
    actionCollection()->addAction( "edit_createanimation", m_actionCreateAnimation );
    connect( m_actionCreateAnimation, SIGNAL( activated() ), this, SLOT( createAnimation() ) );

    m_actionCreateCustomSlideShowsDialog = new KAction( i18n( "Edit Custom Slide Shows..." ), this );
    actionCollection()->addAction( "edit_customslideshows", m_actionCreateCustomSlideShowsDialog );
    connect( m_actionCreateCustomSlideShowsDialog, SIGNAL( activated() ), this, SLOT( dialogCustomSlideShows() ) );

    m_actionStartPresentation = new KActionMenu( KIcon("view-presentation"), i18n( "Start Presentation" ), this );
    actionCollection()->addAction( "slideshow_start", m_actionStartPresentation );
    connect( m_actionStartPresentation, SIGNAL( activated() ), this, SLOT( startPresentation() ) );
    KAction* action = new KAction( i18n( "From Current Slide" ),
this );
    action->setShortcut(QKeySequence("Shift+F5"));
    m_actionStartPresentation->addAction( action );
    connect( action, SIGNAL( activated() ), this, SLOT( startPresentation() ) );
    action = new KAction( i18n( "From First Slide" ), this );
    action->setShortcut(QKeySequence("F5"));
    m_actionStartPresentation->addAction( action );
    connect( action, SIGNAL( activated() ), this, SLOT( startPresentationFromBeginning() ) );

    action = new KAction( i18n( "Configure Slide Show..." ), this );
    actionCollection()->addAction( "slideshow_configure", action );
    connect( action, SIGNAL( activated() ), this, SLOT( configureSlideShow() ) );

    action = new KAction( i18n( "Configure Presenter View..." ), this );
    actionCollection()->addAction( "slideshow_presenterview", action );
    connect( action, SIGNAL( activated() ), this, SLOT( configurePresenterView() ) );

    m_actionDrawOnPresentation = new KAction( i18n( "Draw on the presentation..." ), this );
    m_actionDrawOnPresentation->setShortcut(Qt::Key_P);
    m_actionDrawOnPresentation->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction( "draw_on_presentation", m_actionDrawOnPresentation );
    connect( m_actionDrawOnPresentation, SIGNAL( activated() ), this, SLOT( drawOnPresentation() ) );
    m_actionDrawOnPresentation->setEnabled(false);

    m_actionHighlightPresentation = new KAction( i18n( "Highlight the presentation..." ), this );
    m_actionHighlightPresentation->setShortcut(Qt::Key_H);
    m_actionHighlightPresentation->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction( "highlight_presentation", m_actionHighlightPresentation );
    connect( m_actionHighlightPresentation, SIGNAL( activated() ), this, SLOT( highlightPresentation() ) );
    m_actionHighlightPresentation->setEnabled(false);

    m_actionBlackPresentation = new KAction( i18n( "Blackscreen on the presentation..." ), this );
    m_actionBlackPresentation->setShortcut(Qt::Key_B);
    m_actionBlackPresentation->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction( "black_presentation", m_actionBlackPresentation );
    connect( m_actionBlackPresentation, SIGNAL( activated() ), this, SLOT( blackPresentation() ) );
    m_actionBlackPresentation->setEnabled(false);
}
Exemple #11
0
TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration)
{
    Vector<Dictionary, 0> jsKeyframes;
    RefPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, exceptionState);
    EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
}
Exemple #12
0
void KPrView::initActions()
{
    //setComponentData(KPrFactory::componentData());
    if (!koDocument()->isReadWrite() )
       setXMLFile( "stage_readonly.rc" );
    else
       setXMLFile( "stage.rc" );

#ifdef CAN_USE_QTWEBKIT
    // do special stage stuff here
    m_actionExportHtml = new QAction(i18n("Export as HTML..."), this);
    actionCollection()->addAction("file_export_html", m_actionExportHtml);
    connect(m_actionExportHtml, SIGNAL(triggered()), this, SLOT(exportToHtml()));
#endif

    m_actionViewModeNormal = new QAction(m_normalMode->name(), this);
    m_actionViewModeNormal->setCheckable(true);
    m_actionViewModeNormal->setChecked(true);
    m_actionViewModeNormal->setShortcut(QKeySequence("CTRL+F5"));
    actionCollection()->addAction("view_normal", m_actionViewModeNormal);
    connect(m_actionViewModeNormal, SIGNAL(triggered()), this, SLOT(showNormal()));

    m_actionViewModeNotes = new QAction(m_notesMode->name(), this);
    m_actionViewModeNotes->setCheckable(true);
    m_actionViewModeNotes->setShortcut(QKeySequence("CTRL+F6"));
    actionCollection()->addAction("view_notes", m_actionViewModeNotes);
    connect(m_actionViewModeNotes, SIGNAL(triggered()), this, SLOT(showNotes()));

    m_actionViewModeSlidesSorter = new QAction(m_slidesSorterMode->name(), this);
    m_actionViewModeSlidesSorter->setCheckable(true);
    m_actionViewModeSlidesSorter->setShortcut(QKeySequence("CTRL+F7"));
    actionCollection()->addAction("view_slides_sorter", m_actionViewModeSlidesSorter);
    connect(m_actionViewModeSlidesSorter, SIGNAL(triggered()), this, SLOT(showSlidesSorter()));

    if ( QAction *action = actionCollection()->action("view_masterpages") )
        action->setShortcut(QKeySequence("CTRL+F8"));

    m_actionInsertPictures = new QAction(i18n("Insert Pictures as Slides..."), this);
    actionCollection()->addAction("insert_pictures", m_actionInsertPictures);
    connect(m_actionInsertPictures, SIGNAL(activated()), this, SLOT(insertPictures()));

    QActionGroup *viewModesGroup = new QActionGroup(this);
    viewModesGroup->addAction(m_actionViewModeNormal);
    viewModesGroup->addAction(m_actionViewModeNotes);
    viewModesGroup->addAction(m_actionViewModeSlidesSorter);

    m_actionCreateAnimation = new QAction( i18n( "Create Appear Animation" ), this );
    actionCollection()->addAction( "edit_createanimation", m_actionCreateAnimation );
    connect( m_actionCreateAnimation, SIGNAL(activated()), this, SLOT(createAnimation()) );

    m_actionEditCustomSlideShows = new QAction( i18n( "Edit Custom Slide Shows..." ), this );
    actionCollection()->addAction( "edit_customslideshows", m_actionEditCustomSlideShows );
    connect( m_actionEditCustomSlideShows, SIGNAL(activated()), this, SLOT(editCustomSlideShows()) );

    m_actionStartPresentation = new KActionMenu(koIcon("view-presentation"), i18n("Start Presentation"), this);
    actionCollection()->addAction( "slideshow_start", m_actionStartPresentation );
    connect( m_actionStartPresentation, SIGNAL(activated()), this, SLOT(startPresentation()) );
    QAction* action = new QAction( i18n( "From Current Slide" ), this );
    action->setShortcut(QKeySequence("Shift+F5"));
    m_actionStartPresentation->addAction( action );
    connect( action, SIGNAL(activated()), this, SLOT(startPresentation()) );
    action = new QAction( i18n( "From First Slide" ), this );
    action->setShortcut(QKeySequence("F5"));
    m_actionStartPresentation->addAction( action );
    connect( action, SIGNAL(activated()), this, SLOT(startPresentationFromBeginning()) );

    KToggleAction *showStatusbarAction = new KToggleAction(i18n("Show Status Bar"), this);
    showStatusbarAction->setCheckedState(KGuiItem(i18n("Hide Status Bar")));
    showStatusbarAction->setToolTip(i18n("Shows or hides the status bar"));
    actionCollection()->addAction("showStatusBar", showStatusbarAction);
    connect(showStatusbarAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool)));

    //Update state of status bar action
    if (showStatusbarAction && statusBar()){
        showStatusbarAction->setChecked(! statusBar()->isHidden());
    }

    action = new QAction( i18n( "Configure Slide Show..." ), this );
    actionCollection()->addAction( "slideshow_configure", action );
    connect( action, SIGNAL(activated()), this, SLOT(configureSlideShow()) );

    action = new QAction( i18n( "Configure Presenter View..." ), this );
    actionCollection()->addAction( "slideshow_presenterview", action );
    connect( action, SIGNAL(activated()), this, SLOT(configurePresenterView()) );

    m_actionDrawOnPresentation = new QAction( i18n( "Draw on the presentation..." ), this );
    m_actionDrawOnPresentation->setShortcut(Qt::Key_P);
    m_actionDrawOnPresentation->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction( "draw_on_presentation", m_actionDrawOnPresentation );
    connect( m_actionDrawOnPresentation, SIGNAL(activated()), this, SLOT(drawOnPresentation()) );
    m_actionDrawOnPresentation->setEnabled(false);

    m_actionHighlightPresentation = new QAction( i18n( "Highlight the presentation..." ), this );
    m_actionHighlightPresentation->setShortcut(Qt::Key_H);
    m_actionHighlightPresentation->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction( "highlight_presentation", m_actionHighlightPresentation );
    connect( m_actionHighlightPresentation, SIGNAL(activated()), this, SLOT(highlightPresentation()) );
    m_actionHighlightPresentation->setEnabled(false);

    m_actionBlackPresentation = new QAction( i18n( "Blackscreen on the presentation..." ), this );
    m_actionBlackPresentation->setShortcut(Qt::Key_B);
    m_actionBlackPresentation->setShortcutContext(Qt::ApplicationShortcut);
    actionCollection()->addAction( "black_presentation", m_actionBlackPresentation );
    connect( m_actionBlackPresentation, SIGNAL(activated()), this, SLOT(blackPresentation()) );
    m_actionBlackPresentation->setEnabled(false);

    connect(tabBar(), SIGNAL(currentChanged(int)), this, SLOT(changeViewByIndex(int)));
}
Exemple #13
0
bool NPC1::init()
{
	do 
	{
		CC_BREAK_IF(!Person::initWithSpriteFrameName("Role2Normal1.png"));

		CallFunc *callbackNormal = CallFunc::create(std::bind(&NPC1::normalAction, this));
		CallFunc *callbackJumpEnd = CallFunc::create(std::bind(&NPC1::jumpActionEnd, this));

		Size visibleSize = Director::getInstance()->getVisibleSize();
		Vec2 origin = Director::getInstance()->getVisibleOrigin();

		//Õý³£×´Ì¬Ï¶¯»­
		const char* normalPng = String::createWithFormat("%s%s", roleName, "Normal")->getCString();
		Animation* normalAnimation = createAnimation(normalPng,6,12);
		setNormalAction(RepeatForever::create(Animate::create(normalAnimation)));

		//Òƶ¯×´Ì¬ÏÂ
		//const char* movePng = String::createWithFormat(roleName,"Move")->getCString();
		//Animation* moveAnimation = createAnimation(movePng,6,12);
		setMoveAction(RepeatForever::create(Animate::create(normalAnimation)));

		//¹¥»÷״̬϶¯»­
		const char* firePng = String::createWithFormat("%s%s", roleName, "Fire")->getCString();
		Animation* fireAnimation = createAnimation(firePng,2,10);
		setFireAction(Sequence::create(Animate::create(fireAnimation), callbackNormal, NULL));

		//Êܵ½¹¥»÷״̬϶¯»­
		const char* attackedPng = String::createWithFormat("%s%s", roleName, "Attacked")->getCString();
		Animation* attackedAnimation = createAnimation(attackedPng,3,12);
		setAttackedAction(Sequence::create(Animate::create(attackedAnimation), callbackNormal, NULL));

		//±»¶³×¡×´Ì¬ÏÂ
		const char* frozenPng = String::createWithFormat("%s%s", roleName, "Frozen")->getCString();
		Animation* frozenAnimation = createAnimation(frozenPng,2,10);
		setFrozenAction(Sequence::create(Animate::create(frozenAnimation), DelayTime::create(5), callbackNormal, NULL));

		//±»ºÚ¶´À§×¡×´Ì¬ÏÂ
		const char* holePng = String::createWithFormat("%s%s", roleName, "Hole")->getCString();
		Animation* holeAnimation = createAnimation(holePng,2,10);
		setHoleAction(Sequence::create(Animate::create(holeAnimation), DelayTime::create(5), callbackNormal, NULL));

		//±»Íøס״̬ÏÂ
		const char* netPng = String::createWithFormat("%s%s", roleName, "Net")->getCString();
		Animation* netAnimation = createAnimation(netPng,2,10);
		setNetAction(Sequence::create(Animate::create(netAnimation), DelayTime::create(5), callbackNormal, NULL));

		//ÌøԾ״̬϶¯»­
		auto actionBy = JumpBy::create(1, Vec2(0,0), visibleSize.height/4, 1);
		//auto actionByBack = actionBy->reverse();
		setJumpAction(Sequence::create(actionBy, callbackJumpEnd, NULL));

		//ʤÀû״̬ÏÂ
		const char* victoryPng = String::createWithFormat("%s%s", roleName, "Victory")->getCString();
		Animation* victoryAnimation = createAnimation(victoryPng,2,10);
		setVictoryAction(Sequence::create(Animate::create(victoryAnimation), DelayTime::create(5), NULL));

		//ʧ°Ü״̬ÏÂ
		const char* failPng = String::createWithFormat("%s%s", roleName, "Failure")->getCString();
		Animation* failAnimation = createAnimation(failPng,2,10);
		setFailAction(Sequence::create(Animate::create(failAnimation), DelayTime::create(5), NULL));

		setTotalHP(100);
		setTotalSP(100);

		setHP(100);
		setSP(0);

		return true;
	}while(0);

	return false;
}
    quit(1);
  }*/

  // Table of sprites, ready to use
  SpriteTable * groundTable = splitTextureTable(groundTexture, 48, 48);
  // SpriteTable * characterTable = splitTextureTable(characterTexture, 48, 48);

  // Animations of the character
  SDL_Rect rect;
  rect.x = 0;
  rect.y = 0;
  rect.w = 48;
  rect.h = 48;

  // Stand up
  Animation * stand = createAnimation(characterTexture, &rect, 4, 1);

  // Move
  Animation * goDown = createAnimation(characterTexture, &rect, 4, 4);
  rect.y = 48;
  Animation * goRight = createAnimation(characterTexture, &rect, 4, 4);
  rect.y = 2 * 48;
  Animation * goUp = createAnimation(characterTexture, &rect, 4, 4);
  rect.y = 3 * 48;
  Animation * goLeft = createAnimation(characterTexture, &rect, 4, 4);

  // Sword
  rect.y = 4 * 48;
  Animation * swordRight = createAnimation(characterTexture, &rect, 2, 6);
  rect.y = 5 * 48;
  Animation * swordLeft = createAnimation(characterTexture, &rect, 2, 6);
Exemple #15
0
Animation* AnimationTarget::createAnimation(const char* id, Properties* animationProperties)
{
    assert(animationProperties);
    assert(std::strcmp(animationProperties->getNamespace(), "animation") == 0);
    
    const char* propertyIdStr = animationProperties->getString("property");
    assert(propertyIdStr);
    
    // Get animation target property id
    int propertyId = AnimationTarget::getPropertyId(_targetType, propertyIdStr);
    assert(propertyId != -1);
    
    unsigned int keyCount = animationProperties->getInt("keyCount");
    assert(keyCount > 0);

    const char* keyTimesStr = animationProperties->getString("keyTimes");
    assert(keyTimesStr);
    
    const char* keyValuesStr = animationProperties->getString("keyValues");
    assert(keyValuesStr);
    
    const char* curveStr = animationProperties->getString("curve");
    assert(curveStr);
    
    char delimeter = ' ';
    unsigned int startOffset = 0;
    unsigned int endOffset = (unsigned int)std::string::npos;
    
    unsigned long* keyTimes = new unsigned long[keyCount];
    for (unsigned int i = 0; i < keyCount; i++)
    {
        endOffset = static_cast<std::string>(keyTimesStr).find_first_of(delimeter, startOffset);
        if (endOffset != std::string::npos)
        {
            keyTimes[i] = std::strtoul(static_cast<std::string>(keyTimesStr).substr(startOffset, endOffset - startOffset).c_str(), NULL, 0);
        }
        else
        {
            keyTimes[i] = std::strtoul(static_cast<std::string>(keyTimesStr).substr(startOffset, static_cast<std::string>(keyTimesStr).length()).c_str(), NULL, 0);
        }
        startOffset = endOffset + 1;
    }

    startOffset = 0;
    endOffset = (unsigned int)std::string::npos;
    
    int componentCount = getAnimationPropertyComponentCount(propertyId);
    assert(componentCount > 0);
    
    unsigned int components = keyCount * componentCount;
    
    float* keyValues = new float[components];
    for (unsigned int i = 0; i < components; i++)
    {
        endOffset = static_cast<std::string>(keyValuesStr).find_first_of(delimeter, startOffset);
        if (endOffset != std::string::npos)
        {   
            keyValues[i] = std::atof(static_cast<std::string>(keyValuesStr).substr(startOffset, endOffset - startOffset).c_str());
        }
        else
        {
            keyValues[i] = std::atof(static_cast<std::string>(keyValuesStr).substr(startOffset, static_cast<std::string>(keyValuesStr).length()).c_str());
        }
        startOffset = endOffset + 1;
    }

    const char* keyInStr = animationProperties->getString("keyIn");
    float* keyIn = NULL;
    if (keyInStr)
    {
        keyIn = new float[components];
        startOffset = 0;
        endOffset = (unsigned int)std::string::npos;
        for (unsigned int i = 0; i < components; i++)
        {
            endOffset = static_cast<std::string>(keyInStr).find_first_of(delimeter, startOffset);
            if (endOffset != std::string::npos)
            {   
                keyIn[i] = std::atof(static_cast<std::string>(keyInStr).substr(startOffset, endOffset - startOffset).c_str());
            }
            else
            {
                keyIn[i] = std::atof(static_cast<std::string>(keyInStr).substr(startOffset, static_cast<std::string>(keyInStr).length()).c_str());
            }
            startOffset = endOffset + 1;
        }
    }
    
    const char* keyOutStr = animationProperties->getString("keyOut");
    float* keyOut = NULL;
    if (keyOutStr)
    {   
        keyOut = new float[components];
        startOffset = 0;
        endOffset = (unsigned int)std::string::npos;
        for (unsigned int i = 0; i < components; i++)
        {
            endOffset = static_cast<std::string>(keyOutStr).find_first_of(delimeter, startOffset);
            if (endOffset != std::string::npos)
            {   
                keyOut[i] = std::atof(static_cast<std::string>(keyOutStr).substr(startOffset, endOffset - startOffset).c_str());
            }
            else
            {
                keyOut[i] = std::atof(static_cast<std::string>(keyOutStr).substr(startOffset, static_cast<std::string>(keyOutStr).length()).c_str());
            }
            startOffset = endOffset + 1;
        }
    }

    int curve = Curve::getInterpolationType(curveStr);

    Animation* animation = NULL;
    if (keyIn && keyOut)
    {
        animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, keyIn, keyOut, (Curve::InterpolationType)curve);
    }
    else
    {
        animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
    }

    SAFE_DELETE(keyOut);
    SAFE_DELETE(keyIn);
    SAFE_DELETE(keyValues);
    SAFE_DELETE(keyTimes);

    Properties* pClip = animationProperties->getNextNamespace();
    if (pClip && std::strcmp(pClip->getNamespace(), "clip") == 0)
    {
        int frameCount = animationProperties->getInt("frameCount");
        assert(frameCount > 0);
        animation->createClips(animationProperties, (unsigned int) frameCount);
    }

    return animation;
}