X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fblocks%2Fblocks-example.cpp;h=dc3b208364cbbf96c8bd5310c24eefa7ada11338;hb=0bb1033cc6ab888e7fe5db8268fef8f0b6e83e47;hp=a308be3925f3b646aa6655502719af8d5f25f9df;hpb=2cfafe99d72918b8b1326e0726b9b6ae8e0191f0;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/blocks/blocks-example.cpp b/examples/blocks/blocks-example.cpp index a308be3..dc3b208 100644 --- a/examples/blocks/blocks-example.cpp +++ b/examples/blocks/blocks-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -214,7 +214,29 @@ public: */ ExampleController( Application& application ) : mApplication( application ), - mView() + mView(), + mContentLayer(), + mBall(), + mBallStartPosition(), + mBallVelocity(), + mBallAnimation(), + mPaddle(), + mPaddleImage(), + mPaddleHandle(), + mPaddleHitMargin(), + mWobbleAnimation(), + mWobbleProperty( Property::INVALID_INDEX ), + mLevelContainer(), + mBrickImageMap(), + mDragAnimation(), + mDragActor(), + mRelativeDragPoint(), + mDestroyAnimationMap(), + mPaddleFullSize(), + mLevel( 0 ), + mLives( TOTAL_LIVES ), + mBrickCount( 0 ) + { // Connect to the Application's Init and orientation changed signal mApplication.InitSignal().Connect(this, &ExampleController::Create); @@ -228,6 +250,9 @@ public: { Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleController::OnKeyEvent); + // Hide the indicator bar + application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + // Creates a default view with a default tool bar. // The view is added to the stage. Toolkit::ToolBar toolBar; @@ -362,6 +387,17 @@ private: mBrickCount = 0; + if( mBrickImageMap.Empty() ) + { + Vector2 stageSize(Stage::GetCurrent().GetSize()); + const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x)); + + mBrickImageMap["desiredWidth"] = static_cast( brickSize.width ); + mBrickImageMap["desiredHeight"] = static_cast( brickSize.height ); + mBrickImageMap["fittingMode"] = "SCALE_TO_FILL"; + mBrickImageMap["samplingMode"] = "BOX_THEN_LINEAR"; + } + switch(level%TOTAL_LEVELS) { case 0: @@ -519,14 +555,11 @@ private: */ Actor CreateBrick( const Vector2& position, int type ) { - Vector2 stageSize(Stage::GetCurrent().GetSize()); - const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x)); - - Image img = ResourceImage::New( BRICK_IMAGE_PATH[type], Dali::ImageDimensions( 128, 64 ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); - ImageView brick = ImageView::New(img); + mBrickImageMap["url"] = BRICK_IMAGE_PATH[type]; + ImageView brick = ImageView::New(); + brick.SetProperty( ImageView::Property::IMAGE, mBrickImageMap ); brick.SetParentOrigin(ParentOrigin::TOP_LEFT); brick.SetAnchorPoint(AnchorPoint::CENTER); - brick.SetSize( brickSize ); brick.SetPosition( Vector3( position ) ); // Add a constraint on the brick between it and the ball generating a collision-property @@ -709,7 +742,7 @@ private: void OnHitPaddle(PropertyNotification& source) { Actor delegate = Actor::DownCast(source.GetTarget()); - Vector3 collisionVector = delegate.GetProperty(source.GetTargetProperty()); + Vector3 collisionVector = delegate.GetCurrentProperty< Vector3 >( source.GetTargetProperty() ); Vector3 ballRelativePosition(mBall.GetCurrentPosition() - mPaddle.GetCurrentPosition()); ballRelativePosition.Normalize(); @@ -744,7 +777,7 @@ private: void OnHitBrick(PropertyNotification& source) { Actor brick = Actor::DownCast(source.GetTarget()); - Vector3 collisionVector = brick.GetProperty(source.GetTargetProperty()); + Vector3 collisionVector = brick.GetCurrentProperty< Vector3 >( source.GetTargetProperty() ); const float normalVelocity = fabsf(mBallVelocity.Dot(collisionVector)); mBallVelocity += collisionVector * normalVelocity * 2.0f; @@ -815,6 +848,7 @@ private: Animation mWobbleAnimation; ///< Paddle's animation when hit (wobbles) Property::Index mWobbleProperty; ///< The wobble property (generated from animation) Actor mLevelContainer; ///< The level container (contains bricks) + Property::Map mBrickImageMap; ///< The property map used to load the brick // actor - dragging functionality @@ -828,18 +862,10 @@ private: int mBrickCount; ///< Total bricks on screen. }; -void RunTest(Application& app) -{ - ExampleController test(app); - - app.MainLoop(); -} - int DALI_EXPORT_API main(int argc, char **argv) { Application app = Application::New(&argc, &argv, DEMO_THEME_PATH); - - RunTest(app); - + ExampleController test(app); + app.MainLoop(); return 0; }