harinder Active Member Licensed User Longtime User Jul 14, 2020 #1 Hello..Hope everyone safe in these trying times I am kind of stuck with this animation issue. I have an arrow representing wind as fontawesome in a label. The arrow changes direction as per a user choice as follows: B4X: setRotation(label,spn.SelectedItem) B4X: Sub setRotation(v As View, Angle As Float) Dim jo = v As JavaObject jo.RunMethod("setRotation", Array As Object(Angle)) End Sub It rotates fine. Now, I want to animate it so that it moves in same changed direction certain distance and then back to repeat the animation, to give the wind direction FROM feel. I tried using Animation library as follows: B4X: anim.InitializeTranslate("",0,0,(40*Cos(spn.SelectedItem)),(40*Sin(spn.SelectedItem))) anim.Duration=1000 anim.Repeatcount=-1 anim.Start(label) But, the direction of movement is not correct in few directions. Please help. Rgds..
Hello..Hope everyone safe in these trying times I am kind of stuck with this animation issue. I have an arrow representing wind as fontawesome in a label. The arrow changes direction as per a user choice as follows: B4X: setRotation(label,spn.SelectedItem) B4X: Sub setRotation(v As View, Angle As Float) Dim jo = v As JavaObject jo.RunMethod("setRotation", Array As Object(Angle)) End Sub It rotates fine. Now, I want to animate it so that it moves in same changed direction certain distance and then back to repeat the animation, to give the wind direction FROM feel. I tried using Animation library as follows: B4X: anim.InitializeTranslate("",0,0,(40*Cos(spn.SelectedItem)),(40*Sin(spn.SelectedItem))) anim.Duration=1000 anim.Repeatcount=-1 anim.Start(label) But, the direction of movement is not correct in few directions. Please help. Rgds..
TILogistic Expert Licensed User Longtime User Jul 14, 2020 #2 test: Smooth rotation B4X: 'XUI library Sub setRotation(v As B4XView, Angle As Float) v.SetRotationAnimated(1000,Angle) End Sub Upvote 0
test: Smooth rotation B4X: 'XUI library Sub setRotation(v As B4XView, Angle As Float) v.SetRotationAnimated(1000,Angle) End Sub
E emexes Expert Licensed User Longtime User Jul 15, 2020 #3 Perhaps animate the label WindLabel like: B4X: Sub Process_Globals Private WindLabel As B4XView Private WindFrame As Int Private WindTimer As Timer Sub AppStart (Form1 As Form, Args() As String) WindTimer.Initialize("WindTimer", 100) WindTimer.Enabled = True Sub WindTimer_Tick WindFrame = (WindFrame + 1) Mod 13 '0..12 spaces before arrows' WindLabel.Text = " ➡ ➡ ➡ ➡ ➡".SubString(12 - WindFrame) End Sub and then just rotate the whole animated kit and kaboodle using eg: Code: WindLabel.Rotation = 45 'north-east Last edited: Jul 15, 2020 Upvote 0
Perhaps animate the label WindLabel like: B4X: Sub Process_Globals Private WindLabel As B4XView Private WindFrame As Int Private WindTimer As Timer Sub AppStart (Form1 As Form, Args() As String) WindTimer.Initialize("WindTimer", 100) WindTimer.Enabled = True Sub WindTimer_Tick WindFrame = (WindFrame + 1) Mod 13 '0..12 spaces before arrows' WindLabel.Text = " ➡ ➡ ➡ ➡ ➡".SubString(12 - WindFrame) End Sub and then just rotate the whole animated kit and kaboodle using eg: Code: WindLabel.Rotation = 45 'north-east
TILogistic Expert Licensed User Longtime User Jul 15, 2020 #4 simple demo. B4J. note: convert wind coordinates in angle B4X: Sub setRotation(v As B4XView, Time As Int, Angle As Float) v.SetRotationAnimated(Time,Angle) End Sub correction: press button to see the angle effect Attachments test.zip test.zip 2 KB · Views: 450 Last edited: Jul 15, 2020 Upvote 0
simple demo. B4J. note: convert wind coordinates in angle B4X: Sub setRotation(v As B4XView, Time As Int, Angle As Float) v.SetRotationAnimated(Time,Angle) End Sub correction: press button to see the angle effect
TILogistic Expert Licensed User Longtime User Jul 15, 2020 #5 or use the label and angle effect: note that views have an initial angle Attachments test2.zip test2.zip 2.2 KB · Views: 434 Last edited: Jul 15, 2020 Upvote 0
TILogistic Expert Licensed User Longtime User Jul 15, 2020 #6 test new: Attachments test-new.zip test-new.zip 2.2 KB · Views: 470 Upvote 0
harinder Active Member Licensed User Longtime User Jul 15, 2020 #7 Thank you very much oparra and emexes for the windtimer solution. Thanks really for your time B4X: Sub WindTimer_Tick WindFrame = (WindFrame + 1) Mod 13 '0..12 spaces before arrows' WindLabel.Text = " ➡ ➡ ➡ ➡ ➡".SubString(12 - WindFrame) End Sub I got my animation solution working too, courtesy this one post by Erel(i guess he, like god, is everywhere): How to draw a 30 degree line I know how to draw lines. What I need to do is draw a line at a specific angle, such as 30 degrees. I don't know how to calculate the line angle for the given points of x1, y1, x2, y2? Thanks... www.b4x.com So, I realized I made a silly mistake. I used cos/sin instead of cosD/sinD. cos/sin gives radians, cosD/sinD gives degrees(which is what is required). Hence, this one now works fine too: B4X: anim.InitializeTranslate("",0,0,(40*CosD(spn.SelectedItem)),(40*SinD(spn.SelectedItem))) anim.Duration=1000 anim.Repeatcount=-1 anim.Start(label) Upvote 0
Thank you very much oparra and emexes for the windtimer solution. Thanks really for your time B4X: Sub WindTimer_Tick WindFrame = (WindFrame + 1) Mod 13 '0..12 spaces before arrows' WindLabel.Text = " ➡ ➡ ➡ ➡ ➡".SubString(12 - WindFrame) End Sub I got my animation solution working too, courtesy this one post by Erel(i guess he, like god, is everywhere): How to draw a 30 degree line I know how to draw lines. What I need to do is draw a line at a specific angle, such as 30 degrees. I don't know how to calculate the line angle for the given points of x1, y1, x2, y2? Thanks... www.b4x.com So, I realized I made a silly mistake. I used cos/sin instead of cosD/sinD. cos/sin gives radians, cosD/sinD gives degrees(which is what is required). Hence, this one now works fine too: B4X: anim.InitializeTranslate("",0,0,(40*CosD(spn.SelectedItem)),(40*SinD(spn.SelectedItem))) anim.Duration=1000 anim.Repeatcount=-1 anim.Start(label)
TILogistic Expert Licensed User Longtime User Jul 15, 2020 #8 sorry the solution of the publication, it's from Klaus and ilan I got my animation solution working too, courtesy this one post by Erel(i guess he, like god, is everywhere): Click to expand... effect scrolling label. [B4X] BBScrollingLabel - rich text scrolling label (this is an animated gif, it is is much smoother in real usage) BBScrollingLabel is similar to XUI Views ScrollingLabel, however it is based on BCTextEngine and can therefore display formatted text. It is cross platform. Usage instructions: - Download the b4xlib and put it in the B4X... www.b4x.com or [B4X] XUI Views - Cross platform views and dialogs XUI Views is a b4x library (https://www.b4x.com/android/forum/threads/100383/#content). The same b4xlib library is compatible with B4A, B4i and B4J It is a collection of custom views and dialogs. Everything is written in B4X. The source code is included inside the b4xlib file, which is a zip... www.b4x.com Upvote 0
sorry the solution of the publication, it's from Klaus and ilan I got my animation solution working too, courtesy this one post by Erel(i guess he, like god, is everywhere): Click to expand... effect scrolling label. [B4X] BBScrollingLabel - rich text scrolling label (this is an animated gif, it is is much smoother in real usage) BBScrollingLabel is similar to XUI Views ScrollingLabel, however it is based on BCTextEngine and can therefore display formatted text. It is cross platform. Usage instructions: - Download the b4xlib and put it in the B4X... www.b4x.com or [B4X] XUI Views - Cross platform views and dialogs XUI Views is a b4x library (https://www.b4x.com/android/forum/threads/100383/#content). The same b4xlib library is compatible with B4A, B4i and B4J It is a collection of custom views and dialogs. Everything is written in B4X. The source code is included inside the b4xlib file, which is a zip... www.b4x.com