example: improve follow cursor sample.
authorTaehyub Kim <taehyub.kim@samsung.com>
Fri, 7 May 2021 06:37:36 +0000 (15:37 +0900)
committerHermet Park <chuneon.park@samsung.com>
Mon, 10 May 2021 05:17:08 +0000 (14:17 +0900)
example/resources/flame-and-spark.riv
example/user_interaction_follow_cursor.cpp

index ba95e95..b22942b 100644 (file)
Binary files a/example/resources/flame-and-spark.riv and b/example/resources/flame-and-spark.riv differ
index 51a8c99..e4f482d 100644 (file)
@@ -22,7 +22,6 @@ static rive::Artboard* artboard = nullptr;
 static rive::LinearAnimationInstance* animationInstance;
 static Ecore_Animator *animator = nullptr;
 static Eo* view = nullptr;
-static vector<std::string> rivefiles;
 static double lastTime;
 static Eo* statePopup = nullptr;
 
@@ -113,7 +112,7 @@ Eina_Bool animationLoop(void *data)
 static void runExample(uint32_t* buffer)
 {
     std::string path = RIVE_FILE_DIR;
-    path.append("runtime_color_change.riv");
+    path.append("flame-and-spark.riv");
     loadRiveFile(path.c_str());
 
     //Create a Canvas
@@ -142,12 +141,19 @@ static void mouseMoveCb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, vo
    int posy = ev->cur.canvas.y - viewy + 250;
 
    // Get the root instance
-   auto instance = artboard->find("root");
-   auto node = instance->as<rive::Node>();
+   auto root = artboard->find("root");
+   auto nodeRoot = root->as<rive::Node>();
 
-   // The resource scale is 0.5, so It should be divided by 2
-   node->x(posx / 2);
-   node->y(posy / 2);
+   auto spark = artboard->find("spark");
+   auto nodeSpark = spark->as<rive::Node>();
+
+   // Set root position
+   nodeRoot->x(posx);
+   nodeRoot->y(posy);
+
+   // Set spark position, 400 is the constant
+   nodeSpark->x(posx - 400);
+   nodeSpark->y(posy);
 }
 
 static void setupScreen(uint32_t* buffer)