private void OnRiveWindowTouchEvent(object source, Window.TouchEventArgs e) { Vector2 lp = e.Touch.GetLocalPosition(0); Vector2 sp = e.Touch.GetScreenPosition(0); if (lp.X > 100 && lp.Y > 100 && lp.X < 620 && lp.Y < 620) { isIn = true; } else { isIn = false; } if (preIn != isIn) { preIn = isIn; if (preIn) { // Change Animation State When the cursor is in the bounds rav.EnableAnimation("rollover_in", true); rav.EnableAnimation("rollover_out", false); } else { // Change Animation State When the cursor is out of the bounds rav.EnableAnimation("rollover_in", false); rav.EnableAnimation("rollover_out", true); } } }
public void Activate() { window = NUIApplication.GetDefaultWindow(); defaultLayer = window.GetDefaultLayer(); window.TouchEvent += OnRiveWindowTouchEvent; // Load RiveAnimation File rav = new RiveAnimationView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "rive/flame-and-spark.riv") { Size = new Size(720, 720), }; // Enable RiveAnimation and Play rav.EnableAnimation("idle", true); rav.Play(); playButton = new Button() { Size = new Size(200, 100), Position = new Position(0, 0), Text = "Play" }; playButton.Clicked += (object source, ClickedEventArgs args) => { rav.Play(); }; defaultLayer.Add(rav); defaultLayer.Add(playButton); }
private void OnRiveWindowTouchEvent(object source, Window.TouchEventArgs e) { Vector2 sp = e.Touch.GetScreenPosition(0); PointStateType state = e.Touch.GetState(0); Position screenPos = new Position(sp.X, sp.Y); if (!scroll.ScrollEnabled) { if (state == PointStateType.Down) { startPos = screenPos; scrollPos = scroll.Position; } Position diff = screenPos - startPos; scroll.PositionX = 0.0f; float minmaxY = scrollPos.Y + diff.Y; if (minmaxY > 520) { scroll.PositionY = 520; } else if (minmaxY <= 120) { scroll.PositionY = 120; } else { scroll.PositionY = minmaxY; } float time = (scroll.PositionY - 120) / 400; // Set RiveAnimation Elapsed Time using View Position rav.SetAnimationElapsedTime("Pull", time); if (time < 1.0) { isMoving = true; // Disable RiveAnimations rav.EnableAnimation("Trigger", false); rav.EnableAnimation("Loading", false); } else if (time >= 1.0 && isMoving) { isMoving = false; // Enable RiveAnimations rav.EnableAnimation("Trigger", true); rav.EnableAnimation("Loading", true); scroll.ScrollEnabled = true; scroll.Size = new Size(720, 760); } } else { if (preScrollPositionY == 0) { float diff = scroll.ScrollPosition.Y - preScrollPositionY; if (diff > 5) { scroll.ScrollTo(0, false); scroll.ScrollEnabled = false; scroll.Size = new Size(720, 1160); for (int i = 0; i < 5; i++) { viewItems[i].BackgroundImage = VIEW_BG_PATH[i]; } } } preScrollPositionY = scroll.ScrollPosition.Y; } ravCenterY = (120.0f + scroll.Position.Y) / 2; rav.PositionX = 0.0f; rav.PositionY = ravCenterY - 248.0f; }
public void Activate() { window = NUIApplication.GetDefaultWindow(); defaultLayer = window.GetDefaultLayer(); window.TouchEvent += OnRiveWindowTouchEvent; // Load RiveAnimation File rav = new RiveAnimationView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "rive/space_reload.riv") { Size = new Size(720, 500), Position = new Position(0, 72) }; scroll = new Components.ScrollableBase() { Position = new Position(0, 120), Size = new Size(720, 1160), ScrollingDirection = Components.ScrollableBase.Direction.Vertical, EnableOverShootingEffect = true, HideScrollbar = true, ScrollEnabled = false }; scroll.Scrolling += Scrolling; header = new TextLabel { Text = "Universe", Position = new Position(0, 0), Size = new Size(720, 120), BackgroundColor = new Color(52.0f / 255.0f, 43.0f / 255.0f, 117.0f / 255.0f, 1.0f), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, TextColor = new Color(1.0f, 1.0f, 1.0f, 1.0f), PointSize = 20.0f, }; viewItems = new View[5]; for (int i = 0; i < 5; i++) { viewItems[i] = new View { Position = VIEW_POSITION[i], Size = VIEW_SIZE[i], BackgroundImage = VIEW_BG_PATH[i], Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size(40, 0) } }; TextLabel title = new TextLabel { Size = new Size(550, 70), PointSize = 12.0f, Text = VIEW_TITLE[i], TextColor = VIEW_TITLE_COLOR[i] }; TextLabel text = new TextLabel { Size = new Size(550, 100), PointSize = 9.0f, MultiLine = true, Text = VIEW_TEXT[i], TextColor = new Color(1.0f, 1.0f, 1.0f, 1.0f) }; if (i == 0) { viewItems[i].TouchEvent += OnChangeEarthColor; } else if (i == 1) { viewItems[i].TouchEvent += OnChangeMoonColor; } else if (i == 2) { viewItems[i].TouchEvent += OnChangeSunColor; } else if (i == 3) { viewItems[i].TouchEvent += OnChangeJupiterColor; } viewItems[i].Add(title); viewItems[i].Add(text); scroll.Add(viewItems[i]); } defaultLayer.Add(rav); defaultLayer.Add(scroll); defaultLayer.Add(header); // Enable RiveAnimation and Play rav.EnableAnimation("Idle", true); rav.Play(); }
public void Activate() { window = NUIApplication.GetDefaultWindow(); defaultLayer = window.GetDefaultLayer(); rav = new RiveAnimationView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "rive/buggy.riv") { Size = new Size(500, 500), ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, PositionUsesPivotPoint = true, }; rav.EnableAnimation("idle", true); playButton = new Button() { Size = new Size(200, 100), Position = new Position(0, 0), Text = "Play" }; playButton.Clicked += (object source, ClickedEventArgs args) => { rav.Play(); }; stopButton = new Button() { Size = new Size(200, 100), Position = new Position(200, 0), Text = "Stop" }; stopButton.Clicked += (object source, ClickedEventArgs args) => { rav.Stop(); }; bounceButton = new Button() { Size = new Size(200, 100), Position = new Position(0, 100), Text = "Bounce" }; bounceButton.Clicked += (object source, ClickedEventArgs args) => { rav.EnableAnimation("bouncing", true); }; brokeButton = new Button() { Size = new Size(200, 100), Position = new Position(200, 100), Text = "Broken" }; brokeButton.Clicked += (object source, ClickedEventArgs args) => { rav.EnableAnimation("broken", true); }; fillButton = new Button() { Size = new Size(200, 100), Position = new Position(0, 200), Text = "Fill" }; fillButton.Clicked += (object source, ClickedEventArgs args) => { rav.SetShapeFillColor("grillFillColor", new Color(1.0f, 0.0f, 0.0f, 1.0f)); }; strokeButton = new Button() { Size = new Size(200, 100), Position = new Position(200, 200), Text = "Stroke" }; strokeButton.Clicked += (object source, ClickedEventArgs args) => { rav.SetShapeStrokeColor("grillStrokeColor", new Color(0.0f, 255.0f, 0.0f, 255.0f)); }; opacityButton = new Button() { Size = new Size(200, 100), Position = new Position(400, 200), Text = "Opacity" }; opacityButton.Clicked += (object source, ClickedEventArgs args) => { rav.SetNodeOpacity("front_light", 0.3f); }; scaleButton = new Button() { Size = new Size(200, 100), Position = new Position(0, 300), Text = "Scale" }; scaleButton.Clicked += (object source, ClickedEventArgs args) => { rav.SetNodeScale("front_light", new Vector2(2.0f, 2.0f)); }; rotationButton = new Button() { Size = new Size(200, 100), Position = new Position(200, 300), Text = "Rotation" }; rotationButton.Clicked += (object source, ClickedEventArgs args) => { rav.SetNodeRotation("front_light", new Degree(45.0f)); }; positionButton = new Button() { Size = new Size(200, 100), Position = new Position(400, 300), Text = "Position" }; positionButton.Clicked += (object source, ClickedEventArgs args) => { rav.SetNodePosition("front_light", new Position(100.0f, -50.0f)); }; defaultLayer.Add(rav); defaultLayer.Add(playButton); defaultLayer.Add(stopButton); defaultLayer.Add(bounceButton); defaultLayer.Add(brokeButton); defaultLayer.Add(fillButton); defaultLayer.Add(strokeButton); defaultLayer.Add(opacityButton); defaultLayer.Add(scaleButton); defaultLayer.Add(rotationButton); defaultLayer.Add(positionButton); }