void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) { mAnimation = Animation::New(TRANSITION_DURATION); Dali::Toolkit::DissolveEffectSetCentralLine( mCurrentImage, position, displacement, 0.0f ); mCurrentImage.SetProperty( Toolkit::ImageView::Property::IMAGE, mDissolveEffect ); mAnimation.AnimateTo( Property( mCurrentImage, "uPercentage" ), 1.0f, AlphaFunction::LINEAR ); mNextImage.SetOpacity(0.0f); mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::LINEAR ); if(mUseHighPrecision) { Dali::Toolkit::DissolveEffectSetCentralLine( mNextImage, position, displacement, 1.0f ); mNextImage.SetProperty( Toolkit::ImageView::Property::IMAGE, mDissolveEffect ); mAnimation.AnimateTo( Property( mNextImage, "uPercentage" ), 0.0f, AlphaFunction::LINEAR ); } else { mAnimation.AnimateTo( Property( mNextImage, Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), AlphaFunction::LINEAR ); } mAnimation.FinishedSignal().Connect( this, &DissolveEffectApp::OnTransitionCompleted ); mAnimation.Play(); mIsTransiting = true; }
/** * Resumes animation for another ANIMATION_DURATION seconds. */ void ContinueAnimation() { Animation animation = Animation::New(ANIMATION_DURATION); mAnimationTime += ANIMATION_DURATION; animation.AnimateTo( Property(mBouncingMagnifier, mAnimationTimeProperty), mAnimationTime ); animation.Play(); animation.FinishedSignal().Connect(this, &ExampleController::OnAnimationFinished); }
int main () { printf ("Results of animation2_test:\n"); try { AnimationManager manager; manager.LoadResource ("data/test.xanim"); Node::Pointer node = Node::Create (), target1 = Node::Create (), target2 = Node::Create (); target1->SetName ("target1"); target2->SetName ("target2"); target1->BindToParent (*node); target2->BindToParent (*node); Animation animation = manager.PlayAnimation ("animation1", *node, &event_handler); animation.RegisterEventHandler (AnimationEvent_OnPlay, &event_handler); animation.RegisterEventHandler (AnimationEvent_OnPause, &event_handler); animation.RegisterEventHandler (AnimationEvent_OnStop, &event_handler); animation.RegisterEventHandler (AnimationEvent_OnUpdate, &event_handler); animation.RegisterEventHandler (AnimationEvent_OnDestroy, &event_handler); printf ("animation duration: %.2f\n", animation.Duration ()); node->Update (TimeValue (2, 1)); node->Update (TimeValue (3, 1)); animation.Pause (); animation.Pause (); node->Update (TimeValue (4, 1)); printf ("animation offset %.2f\n", animation.Tell ()); animation.Play (); animation.Play (); node->Update (TimeValue (5, 1)); printf ("animation offset %.2f\n", animation.Tell ()); animation.Stop (); node->Update (TimeValue (6, 1)); printf ("animation offset %.2f\n", animation.Tell ()); } catch (std::exception& e) { printf ("%s\n", e.what ()); } return 0; }
int UtcDaliBubbleEmitterRestore(void) { ToolkitTestApplication application; tet_infoline( " UtcDaliBubbleEmitterRestore " ); Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 ); BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 90, Vector2( 5.f, 10.f )); Actor root = emitter.GetRootActor(); Stage::GetCurrent().Add( root ); root.SetPosition( Vector3::ZERO ); root.SetParentOrigin( ParentOrigin::CENTER ); root.SetAnchorPoint( AnchorPoint::CENTER ); Actor bubbleMesh = root.GetChildAt( 0 ); Renderer renderer = bubbleMesh.GetRendererAt( 0 ); DALI_TEST_CHECK( renderer ); TestGlAbstraction& gl = application.GetGlAbstraction(); float percentageValue; Vector4 startEndPosValue; Animation animation = Animation::New( 0.5f ); emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) ); Wait(application); DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) ); DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION ); DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) ); DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION ); DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION ); animation.Play(); Wait(application, 200); animation.Clear(); DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) ); DALI_TEST_CHECK( percentageValue < 0.5f && percentageValue >= 0.4); DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) ); DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION ); DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION ); emitter.Restore(); application.SendNotification(); application.Render(); DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) ); DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION ); DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) ); DALI_TEST_EQUALS( startEndPosValue, Vector4::ZERO, TEST_LOCATION ); END_TEST; }
int UtcDaliControlImplSizeAnimation(void) { ToolkitTestApplication application; { DummyControl dummy = DummyControl::New( true ); DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation()); Stage::GetCurrent().Add(dummy); DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION ); Animation animation = Animation::New(1.0f); animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f)); animation.Play(); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, true, TEST_LOCATION ); Stage::GetCurrent().Remove(dummy); } // Ensure full code coverage { DummyControl dummy = DummyControl::New(); Stage::GetCurrent().Add(dummy); Animation animation = Animation::New(1.0f); animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f)); animation.Play(); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); Stage::GetCurrent().Remove(dummy); } END_TEST; }
/** * Hides the magnifier */ void HideMagnifier() { if(mMagnifierShown) { Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); animation.AnimateTo(Property(mMagnifier, Actor::Property::SCALE), Vector3::ZERO, AlphaFunction::EASE_OUT); animation.Play(); mMagnifierShown = false; } }
/** * Shows the magnifier */ void ShowMagnifier() { if(!mMagnifierShown) { Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); animation.AnimateTo(Property(mMagnifier, Actor::Property::SCALE), Vector3::ONE, AlphaFunction::EASE_IN); animation.Play(); mMagnifierShown = true; } }
int UtcDaliShaderAnimatedProperty02(void) { TestApplication application; tet_infoline("Test that a uniform map shader property can be animated"); Shader shader = Shader::New(VertexSource, FragmentSource); Material material = Material::New( shader ); material.SetProperty(Material::Property::COLOR, Color::WHITE); Geometry geometry = CreateQuadGeometry(); Renderer renderer = Renderer::New( geometry, material ); Actor actor = Actor::New(); actor.AddRenderer(renderer); actor.SetSize(400, 400); Stage::GetCurrent().Add(actor); application.SendNotification(); application.Render(0); Vector4 initialColor = Color::WHITE; Property::Index colorIndex = shader.RegisterProperty( "uFadeColor", initialColor ); TestGlAbstraction& gl = application.GetGlAbstraction(); application.SendNotification(); application.Render(0); Vector4 actualValue(Vector4::ZERO); DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) ); DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION ); Animation animation = Animation::New(1.0f); KeyFrames keyFrames = KeyFrames::New(); keyFrames.Add(0.0f, initialColor); keyFrames.Add(1.0f, Color::TRANSPARENT); animation.AnimateBetween( Property( shader, colorIndex ), keyFrames ); animation.Play(); application.SendNotification(); application.Render(500); DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) ); DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION ); application.Render(500); DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) ); DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION ); END_TEST; }
void Stage_Ending::Init() { timer = 0; TextureManager::GetSingleton().Add(L"data\\ending\\background.png"); TextureManager::GetSingleton().Add(L"data\\ending\\flag.png"); TextureManager::GetSingleton().Init(); Entity *newEntity = new Entity(L"data\\ending\\background.png", 800, 600); newEntity->SetPos(0, 0); entities.push_back(newEntity); Animation *newAnimation = new Animation(L"data\\ending\\flag.png", 2000, 120, 1, 20); newAnimation->SetPos(236, 200); newAnimation->Play(15.0f, true); entities.push_back(newAnimation); }
int UtcDaliPropertyNotificationOrder(void) { TestApplication application; // Reset all test adapter return codes Actor actor = Actor::New(); Stage::GetCurrent().Add(actor); // this should complete in first frame PropertyNotification notification1 = actor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(90.0f) ); notification1.NotifySignal().Connect( &TestCallback ); // this should complete in second frame PropertyNotification notification2 = actor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(150.0f) ); notification2.NotifySignal().Connect( &TestCallback2 ); Animation animation = Animation::New( 0.032f ); // finishes in 32 ms animation.AnimateTo( Property(actor, Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), AlphaFunction::LINEAR ); animation.Play(); // flush the queue application.SendNotification(); // first frame application.Render(RENDER_FRAME_INTERVAL); // no notifications yet DALI_TEST_EQUALS( gCallBackCalled, false, TEST_LOCATION ); DALI_TEST_EQUALS( gCallBack2Called, false, TEST_LOCATION ); gCallBackCalled = false; gCallBack2Called = false; // dont serve the notifications but run another update & render // this simulates situation where there is a notification in event side but it's not been picked up by event thread // second frame application.Render(RENDER_FRAME_INTERVAL); DALI_TEST_EQUALS( gCallBackCalled, false, TEST_LOCATION ); DALI_TEST_EQUALS( gCallBack2Called, false, TEST_LOCATION ); // serve the notifications application.SendNotification(); DALI_TEST_EQUALS( gCallBackCalled, true, TEST_LOCATION ); DALI_TEST_EQUALS( gCallBack2Called, true, TEST_LOCATION ); gCallBackCalled = false; gCallBack2Called = false; application.Render(RENDER_FRAME_INTERVAL); application.SendNotification(); DALI_TEST_EQUALS( gCallBackCalled, false, TEST_LOCATION ); DALI_TEST_EQUALS( gCallBack2Called, false, TEST_LOCATION ); END_TEST; }
int UtcDaliBubbleEmitterEmitBubble(void) { ToolkitTestApplication application; tet_infoline( " UtcDaliBubbleEmitterEmitBubble " ); Image shapeImage1 = CreateSolidColorImage( application, Color::GREEN, 5, 5 ); BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage1, 200, Vector2( 5.f, 10.f )); Actor root = emitter.GetRootActor(); Actor bubbleMesh = root.GetChildAt( 0 ); Stage::GetCurrent().Add( root ); DALI_TEST_CHECK( bubbleMesh ); Property::Index propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" ); Property::Index propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" ); float value0, value1; Animation animation = Animation::New( 0.5f ); emitter.EmitBubble( animation, Vector2(40.f,40.f), Vector2(-5.f,-5.f), Vector2(30.f,30.f) ); emitter.EmitBubble( animation, Vector2(10.f,10.f), Vector2(5.f,5.f), Vector2(30.f,30.f) ); (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 ); (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 ); DALI_TEST_EQUALS(value0, 0.f, TEST_LOCATION ); DALI_TEST_EQUALS(value1, 0.f, TEST_LOCATION ); animation.Play(); Wait(application, 300); propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" ); propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" ); (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 ); (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 ); DALI_TEST_CHECK( value0 >= 0.6f ); DALI_TEST_CHECK( value1 >= 0.6f ); Wait(application,500); (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 ); (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 ); DALI_TEST_EQUALS(value0, 1.f, TEST_LOCATION ); DALI_TEST_EQUALS(value1, 1.f, TEST_LOCATION ); END_TEST; }
// The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { //std::cout << "HelloWorldController::Create" << std::endl; // Get a handle to the stage Stage stage = Stage::GetCurrent(); //ImageActor bgActor = ImageActor::New(CreateBitmapImage(480, 800)); Control bgActor = Control::New(); bgActor.SetSize(64 * STAGE_COL, 64 * STAGE_ROW); //bgActor.SetBackgroundColor(Vector4(.125f, .125f, .125f, 1.f)); bgActor.SetBackgroundColor(Vector4(1.f, 1.f, 1.f, 1.f)); bgActor.SetParentOrigin(ParentOrigin::CENTER); bgActor.SetAnchorPoint(AnchorPoint::CENTER); bgActor.SetZ(0.1f); //stage.Add(bgActor); ResourceImage spriteImage = ResourceImage::New(PUYO_IMAGE); // background { ResourceImage image = ResourceImage::New(BACKGROUND_IMAGE); ImageActor actor = ImageActor::New(image); actor.SetParentOrigin(ParentOrigin::BOTTOM_LEFT); actor.SetAnchorPoint(AnchorPoint::BOTTOM_LEFT); stage.Add(actor); } // sprites { ImageActor actor[STAGE_COL * STAGE_ROW]; for (int i = 0; i < STAGE_ROW; i++) { for (int j = 0; j < STAGE_COL; j++) { actor[i * STAGE_COL + j] = ImageActor::New(spriteImage, PUYO_OFFSET[int(Random::Range(0.f, NUM_PUYO))]); actor[i * STAGE_COL + j].SetParentOrigin(ParentOrigin::BOTTOM_LEFT); actor[i * STAGE_COL + j].SetAnchorPoint(AnchorPoint::BOTTOM_LEFT); actor[i * STAGE_COL + j].SetX(i * 60.f); actor[i * STAGE_COL + j].SetY(j * -1.f * 60.f); actor[i * STAGE_COL + j].SetZ(0.1f); stage.Add(actor[i * STAGE_COL + j]); } } #if 0 Animation anim = Animation::New(1.f); for (int i = 0; i < STAGE_ROW; i++) { for (int j = 0; j < STAGE_COL; j++) { anim.MoveBy(actor[i * STAGE_COL + j], Vector3(0.f, j * _(7), 0.1f), AlphaFunctions::Bounce); anim.Resize(actor[i * STAGE_COL + j], _(32), _(25), AlphaFunctions::Bounce); anim.SetLooping(true); } } anim.Play(); #endif } { ImageActor actor = ImageActor::New(spriteImage, ImageActor::PixelArea(0, 224, 64, 64)); actor.SetParentOrigin(ParentOrigin::CENTER); actor.SetAnchorPoint(AnchorPoint::CENTER); actor.SetSize(_(32), _(32)); actor.SetZ(0.1f); //stage.Add(actor); } // Respond to a click anywhere on the stage stage.GetRootLayer().TouchedSignal().Connect( this, &HelloWorldController::OnTouch ); }
void Stage_Stage3::Init() { stageOverTimer = 0; boatTimer = 0; stageClearTimer = 0; bulletCount = 0; GameStateManager::GetSingleton().Init(); Entity *newEntity; #pragma region Texture TextureManager& tm = TextureManager::GetSingleton(); tm.Add(T_BACKGROUND_1); tm.Add(T_BACKGROUND_2); tm.Add(T_BACKGROUND_3); tm.Add(T_BACKGROUND_4); tm.Add(T_BACKGROUND_5); tm.Add(T_ENEMY_1); tm.Add(T_ENEMY_2); tm.Add(T_ENEMY_3); tm.Add(T_ENEMY_BOAT); tm.Add(T_ENEMY_BOSS); tm.Add(T_EXPLOSION); tm.Add(T_EXPLOSION_BIG); tm.Add(T_PLAYER); tm.Add(T_PLAYER_BOAT); tm.Add(T_PLAYER_ADDON); tm.Add(T_BULLET); tm.Add(T_BOAT_BULLET); tm.Add(T_BULLET_2); tm.Add(T_BULLET2_EXPLOSION); tm.Add(T_BULLET_SHELL); tm.Add(T_BULLET_EXPLOSION); tm.Add(T_UI_BACKGROUND_1); tm.Add(T_UI_BACKGROUND_2); tm.Add(T_UI_BAR_HEALTH); tm.Add(T_UI_BAR_EXP); tm.Add(T_UI_SHOP_POWER); tm.Add(T_UI_SHOP_MORESPEED); tm.Add(T_UI_SHOP_SPEED); tm.Add(T_UI_SHOP_ADDON); tm.Add(T_UI_SHOP_WEAPON); tm.Add(T_UI_BAR_BOSS); tm.Add(T_UI_GAMEOVER); tm.Add(T_UI_BAR_BOSS_BG); tm.Add(T_UI_BAR_BOSS_BG_BLACK); tm.Add(T_UI_CLEAR); tm.Add(T_DOKDO); tm.Add(T_HP); tm.Init(); #pragma endregion Texture #pragma region Background newEntity = new Entity(T_BACKGROUND_1, 800, 600); newEntity->SetPos(0, 0); entities.push_back(newEntity); newEntity = new Entity(T_DOKDO, 454, 209); newEntity->SetPos(200, 300); newEntity->Params["Name"] = "Dokdo"; newEntity->SetSpeed(-30, 0, 0, 0); entities.push_back(newEntity); newEntity = new Entity(T_BACKGROUND_2, 1600, 600); newEntity->SetPos(0, 0); newEntity->Params["Type"] = "ScrollingBackground"; newEntity->SetSpeed(-150, 0, 0, 0); entities.push_back(newEntity); newEntity = new Entity(T_BACKGROUND_3, 1600, 600); newEntity->SetPos(0, 0); newEntity->Params["Type"] = "ScrollingBackground"; newEntity->SetSpeed(-200, 0, 0, 0); entities.push_back(newEntity); newEntity = new Entity(T_BACKGROUND_4, 1600, 600); newEntity->SetPos(0, 0); newEntity->Params["Type"] = "ScrollingBackground"; newEntity->SetSpeed(-250, 0, 0, 0); entities.push_back(newEntity); newEntity = new Entity(T_BACKGROUND_5, 1600, 600); newEntity->SetPos(0, 0); newEntity->Params["Type"] = "ScrollingBackground"; newEntity->SetSpeed(-300, 0, 0, 0); entities.push_back(newEntity); #pragma endregion Background #pragma region Player AddNewPlayer(); AddNewPlayerBoat(); Animation *newAddon = new Animation(T_PLAYER_ADDON, 150, 17, 1, 6); newAddon->Params["Type"] = "PlayerAddon"; newAddon->Params["Name"] = "AddonUpper"; newAddon->Play(30.0f, true); entities.push_back(newAddon); newAddon = new Animation(T_PLAYER_ADDON, 150, 17, 1, 6); newAddon->Params["Type"] = "PlayerAddon"; newAddon->Params["Name"] = "AddonLower"; newAddon->Play(30.0f, true); entities.push_back(newAddon); #pragma endregion Player #pragma region Enemy NpcManager& npcManager = NpcManager::GetSingleton(); npcManager.RespawnTime = 2.5; npcManager.Init(&entities); Enemy *newEnemy = new Enemy(T_ENEMY_1, 503, 115, 2, 6); newEnemy->SetSpeed(-100, 0, 0, 0); newEnemy->Params["Name"] = "EnemyPlane"; newEnemy->Params["EnemyType"] = "1"; newEnemy->Params["Collide"] = "Player"; SetRect(&newEnemy->HitMod, 0, -20, 0, 20); npcManager.Add(newEnemy); newEnemy = new Enemy(T_ENEMY_2, 503, 115, 2, 6); newEnemy->SetSpeed(-100, 0, 0, 0); newEnemy->Params["Name"] = "EnemyPlane"; newEnemy->Params["EnemyType"] = "2"; newEnemy->Params["Collide"] = "Player"; SetRect(&newEnemy->HitMod, 0, -20, 0, 20); npcManager.Add(newEnemy); #pragma endregion Enemy #pragma region Animation AnimationAdder &animAddr = AnimationAdder::GetSingleton(); animAddr.Init(&entities); Animation *newAnimation = new Animation(T_BULLET, 80, 20, 1, 4); newAnimation->Params["Type"] = "Player"; newAnimation->Params["Name"] = "PlayerBullet"; newAnimation->Play(20.0f, false); newAnimation->SetSpeed(280, 0, 0, 0); newAnimation->Health = 1; newAnimation->Power = 25; newAnimation->AutoRemove = true; animAddr.Add("PlayerBullet", newAnimation); newAnimation = new Animation(T_BOAT_BULLET, 13, 42, 1, 1); newAnimation->Params["Type"] = "Player"; newAnimation->Params["Name"] = "PlayerBullet"; newAnimation->SetSpeed(0, -300, 0, -20); newAnimation->Health = 1; newAnimation->Power = 50; newAnimation->AutoRemove = true; animAddr.Add("PlayerBoatBullet", newAnimation); newAnimation = new Animation(T_BULLET, 80, 20, 1, 4); newAnimation->Params["Type"] = "Player"; newAnimation->Params["Name"] = "PlayerAddonBullet"; newAnimation->Play(20.0f, false); newAnimation->SetSpeed(280, 0, 0, 0); newAnimation->Health = 1; newAnimation->Power = 10; newAnimation->AutoRemove = true; animAddr.Add("PlayerAddonBullet", newAnimation); newAnimation = new Animation(T_BULLET_2, 100, 20, 1, 5); newAnimation->Params["Type"] = "Player"; newAnimation->Params["Name"] = "PlayerBullet2"; newAnimation->Play(20.0f, false); newAnimation->SetSpeed(300, 0, 0, 0); newAnimation->Health = 1; newAnimation->Power = 50; newAnimation->AutoRemove = true; animAddr.Add("PlayerBullet2", newAnimation); newAnimation = new Animation(T_BULLET, 80, 20, 1, 4); newAnimation->Params["Collide"] = "Player"; newAnimation->Params["Name"] = "EnemyBullet"; newAnimation->Play(20.0f, false); newAnimation->Health = 15; newAnimation->Power = 25; newAnimation->AutoRemove = true; animAddr.Add("EnemyBullet", newAnimation); newAnimation = new Animation(T_BULLET_EXPLOSION, 90, 30, 1, 3); newAnimation->Play(20.0f, false); newAnimation->Params["DeleteWhenEnds"] = "True"; animAddr.Add("BulletCrash", newAnimation); newAnimation = new Animation(T_BULLET2_EXPLOSION, 90, 30, 1, 3); newAnimation->Play(20.0f, false); newAnimation->Params["DeleteWhenEnds"] = "True"; animAddr.Add("BulletCrash2", newAnimation); newAnimation = new Animation(T_EXPLOSION_BIG, 1500, 150, 1, 5); newAnimation->Play(10.0f, false); newAnimation->Params["DeleteWhenEnds"] = "True"; animAddr.Add("Explosion_Big", newAnimation); newAnimation = new Animation(T_EXPLOSION, 1200, 200, 1, 6); newAnimation->Play(20.0f, false); newAnimation->Params["DeleteWhenEnds"] = "True"; animAddr.Add("Explosion", newAnimation); #pragma endregion Animation #pragma region Particle ParticleAdder& particleAdder = ParticleAdder::GetSingleton(); particleAdder.Init(&entities); Particle *newParticle = new Particle(T_BULLET_SHELL, 15, 5); particleAdder.Add("BulletShell", newParticle); #pragma endregion Particle #pragma region UI newEntity = new Entity(T_UI_BACKGROUND_1, 800, 600); newEntity->SetPos(0, 0); newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newEntity = new Entity(T_UI_BAR_HEALTH, 160, 19); newEntity->SetPos(30, 530); newEntity->Params["Name"] = "Bar_Health"; newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newEntity = new Entity(T_UI_BAR_EXP, 160, 19); newEntity->SetPos(30, 556); newEntity->Params["Name"] = "Bar_Exp"; newEntity->Params["DrawLater"] = "True"; newEntity->Width = 0; entities.push_back(newEntity); newEntity = new Entity(T_UI_BAR_BOSS_BG_BLACK, 800, 600); newEntity->SetPos(800, 0); newEntity->Params["Name"] = "Bar_Boss_BG"; newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newEntity = new Entity(T_UI_BAR_BOSS, 709, 21); newEntity->SetPos(845, 80); newEntity->Params["Name"] = "Bar_Boss"; newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newEntity = new Entity(T_UI_BAR_BOSS_BG, 800, 600); newEntity->SetPos(800, 0); newEntity->Params["Name"] = "Bar_Boss_BG"; newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newAnimation = new Animation(T_UI_SHOP_POWER, 600, 50, 1, 6); newAnimation->SetPos(335, 528); newAnimation->Params["Type"] = "ShopItem"; newAnimation->Params["Name"] = "Shop_Power"; newAnimation->Params["DrawLater"] = "True"; entities.push_back(newAnimation); newAnimation = new Animation(T_UI_SHOP_SPEED, 600, 50, 1, 6); newAnimation->SetPos(430, 528); newAnimation->Params["Type"] = "ShopItem"; newAnimation->Params["Name"] = "Shop_Speed"; newAnimation->Params["DrawLater"] = "True"; entities.push_back(newAnimation); newAnimation = new Animation(T_UI_SHOP_MORESPEED, 600, 50, 1, 6); newAnimation->SetPos(516, 528); newAnimation->Params["Type"] = "ShopItem"; newAnimation->Params["Name"] = "Shop_MoreSpeed"; newAnimation->Params["DrawLater"] = "True"; entities.push_back(newAnimation); newAnimation = new Animation(T_UI_SHOP_ADDON, 600, 50, 1, 6); newAnimation->SetPos(602, 528); newAnimation->Params["Type"] = "ShopItem"; newAnimation->Params["Name"] = "Shop_Addon"; newAnimation->Params["DrawLater"] = "True"; entities.push_back(newAnimation); newAnimation = new Animation(T_UI_SHOP_WEAPON, 600, 50, 1, 6); newAnimation->SetPos(694, 528); newAnimation->Params["Type"] = "ShopItem"; newAnimation->Params["Name"] = "Shop_Weapon"; newAnimation->Params["DrawLater"] = "True"; entities.push_back(newAnimation); newEntity = new Entity(T_UI_BACKGROUND_2, 800, 600); newEntity->SetPos(0, 0); newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); Font *newFont = new Font(L"Candara", 190, 40, 40, 15, FW_BOLD, false); newFont->SetPos(90, -3); newFont->Params["DrawLater"] = "True"; newFont->Params["Name"] = "Text_Score"; newFont->SetColor(D3DCOLOR_ARGB(255, 255, 0, 0)); entities.push_back(newFont); newFont = new Font(L"Candara", 35, 40, 40, 15, FW_BOLD, false); newFont->SetPos(260, 540); newFont->Params["DrawLater"] = "True"; newFont->Params["Name"] = "Text_Level"; newFont->SetColor(D3DCOLOR_ARGB(255, 255, 255, 0)); entities.push_back(newFont); newEntity = new Entity(T_HP, 42, 33); newEntity->SetPos(10, 470); newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newFont = new Font(L"Candara", 40, 40, 40, 15, FW_BOLD, false); newFont->SetPos(60, 465); newFont->Params["DrawLater"] = "True"; newFont->Params["Text"] = "x"; newFont->SetColor(D3DCOLOR_ARGB(255, 255, 0, 0)); entities.push_back(newFont); newFont = new Font(L"Candara", 40, 40, 40, 15, FW_BOLD, false); newFont->SetPos(80, 465); newFont->Params["DrawLater"] = "True"; newFont->Params["Name"] = "Text_Life"; newFont->SetColor(D3DCOLOR_ARGB(255, 255, 0, 0)); entities.push_back(newFont); newEntity = new Entity(T_UI_CLEAR, 800, 600); newEntity->SetPos(800, 0); newEntity->Params["Name"] = "Text_Clear"; newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); newEntity = new Entity(T_UI_GAMEOVER, 800, 600); newEntity->SetPos(800, 0); newEntity->Params["Name"] = "Text_Over"; newEntity->Params["DrawLater"] = "True"; entities.push_back(newEntity); #pragma endregion UI }
int UtcDaliModelBuildAnimation01(void) { TestApplication application; TestPlatformAbstraction& platform = application.GetPlatform(); tet_infoline("Testing Dali::MeshActor::New()"); Dali::ModelData modelData = BuildTreeModel(); // Raise a request Model model = Model::New("Tree"); application.SendNotification(); application.Render(); Integration::ResourceRequest* request = platform.GetRequest(); // Return modelData if(request) { platform.SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(&(modelData.GetBaseObject()))); } application.Render(); application.SendNotification(); Actor actor = ModelActorFactory::BuildActorTree(model, ""); // model should be loaded Stage::GetCurrent().Add(actor); DALI_TEST_CHECK(model.GetLoadingState() == ResourceLoadingSucceeded); DALI_TEST_CHECK(actor); DALI_TEST_CHECK(actor.GetName().compare("root") == 0); DALI_TEST_EQUALS(model.NumberOfAnimations(), static_cast<size_t>(1), TEST_LOCATION); unsigned int animIndex=0; bool found = model.FindAnimation("Anim1", animIndex); DALI_TEST_CHECK(found); Animation twigAnim = ModelActorFactory::BuildAnimation(model, actor, animIndex); DALI_TEST_CHECK(twigAnim); DALI_TEST_EQUALS(twigAnim.GetDuration(), 10.0f, 0.001, TEST_LOCATION); DALI_TEST_CHECK(twigAnim.GetDefaultAlphaFunction() == Dali::AlphaFunctions::Linear); Actor twigActor = actor.FindChildByName("twig"); DALI_TEST_CHECK(twigActor); // Start the animation twigAnim.Play(); float durationSeconds = 10.0f; bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); twigAnim.FinishedSignal().Connect(&application, finishCheck); application.SendNotification(); application.Render(); finishCheck.CheckSignalNotReceived(); DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(2.0f, 1.0f, 0.0f), 0.01f, TEST_LOCATION ); application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */); application.SendNotification(); DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(2.5f, 1.0f, 2.5f), 0.01f, TEST_LOCATION ); application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* 75% progress */); application.SendNotification(); DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(3.5f, 1.0f, 7.5f), 0.01f, TEST_LOCATION ); application.Render(static_cast<unsigned int>(durationSeconds*500.0f)/* Past Finished */); application.SendNotification(); DALI_TEST_EQUALS( twigActor.GetCurrentPosition(), Vector3(4.0f, 1.0f, 10.0f), 0.01f, TEST_LOCATION ); finishCheck.CheckSignalReceived(); END_TEST; }