tufanv Expert Licensed User Longtime User Aug 14, 2015 #1 Hello, I also need advice on another thing. Please see the pic below. I need to rotate a circle picture or a circle around a circle track conitnously. ( you can think of world turning around the sun on a track ) . What is the best and easiest way to do it ? TY
Hello, I also need advice on another thing. Please see the pic below. I need to rotate a circle picture or a circle around a circle track conitnously. ( you can think of world turning around the sun on a track ) . What is the best and easiest way to do it ? TY
JanPRO Well-Known Member Licensed User Longtime User Aug 14, 2015 #2 Hi, for the best result you have to use for now (unfortunately) inline objective c code: http://nachbaur.com/blog/core-animation-part-4 Last edited: Aug 14, 2015 Upvote 0
Hi, for the best result you have to use for now (unfortunately) inline objective c code: http://nachbaur.com/blog/core-animation-part-4
narek adonts Well-Known Member Licensed User Longtime User Aug 14, 2015 #3 You can draw a Circle and save all the coordiantes of the path and after use a timer to change the center of the circle Upvote 0
You can draw a Circle and save all the coordiantes of the path and after use a timer to change the center of the circle
narek adonts Well-Known Member Licensed User Longtime User Aug 14, 2015 #4 Attached small project demonstrating your issue. I use my code module in the project to get and set the center of a view, but if you dont like it you can do the same with setting the left and top props. Attachments Rotate.zip Rotate.zip 3.2 KB · Views: 391 Upvote 0
Attached small project demonstrating your issue. I use my code module in the project to get and set the center of a view, but if you dont like it you can do the same with setting the left and top props.
S strat Active Member Licensed User Longtime User Aug 14, 2015 #5 An imageview's moving along circle track is here: Code: Sub Activity_Create(FirstTime As Boolean) angle=0 radius=40%x End Sub This is main code: X and Y variables keep ImageView's circular coordinates. You should edit to work in B4I, add variables, timer etc. Code: Sub timer1_Tick angle=angle+1 x=CosD(angle)*radius+50%x y=SinD(angle)*radius+50%y ImageView1.Left=x ImageView1.Top=y End Sub Edit : This is almost same as narek adonts sample. I didn't see it before post this. Last edited: Aug 14, 2015 Upvote 0
An imageview's moving along circle track is here: Code: Sub Activity_Create(FirstTime As Boolean) angle=0 radius=40%x End Sub This is main code: X and Y variables keep ImageView's circular coordinates. You should edit to work in B4I, add variables, timer etc. Code: Sub timer1_Tick angle=angle+1 x=CosD(angle)*radius+50%x y=SinD(angle)*radius+50%y ImageView1.Left=x ImageView1.Top=y End Sub Edit : This is almost same as narek adonts sample. I didn't see it before post this.
tufanv Expert Licensed User Longtime User Aug 14, 2015 #6 Thank you very much for your examples ! Upvote 0
narek adonts Well-Known Member Licensed User Longtime User Aug 14, 2015 #7 see attached project. It use CAAnimation to be more smooth that the one with the timer. Narek Attachments Rotate2.zip Rotate2.zip 3.7 KB · Views: 381 Upvote 0
tufanv Expert Licensed User Longtime User Aug 15, 2015 #8 Yea i will tey it when i get home thanks ! Upvote 0
tufanv Expert Licensed User Longtime User Aug 15, 2015 #9 narek adonts said: see attached project. It use CAAnimation to be more smooth that the one with the timer. Narek Click to expand... Narek, It is really smooth now ! Thank you Very much for your help . Upvote 0
narek adonts said: see attached project. It use CAAnimation to be more smooth that the one with the timer. Narek Click to expand... Narek, It is really smooth now ! Thank you Very much for your help .
tufanv Expert Licensed User Longtime User Aug 15, 2015 #10 narek adonts said: see attached project. It use CAAnimation to be more smooth that the one with the timer. Narek Click to expand... I have made a small change on the code ( added a panel and initialized the circle on the new panel. btw i dont know why but i had to change the left and top values while adding the circle to panel to a minus otherwise there are 2 circles ,1 is staying at its posiion and other one is circling . you can try it by changing the : paneloyun.AddView(pnlCircle,-100,-50,20,20)to its actual positions on your code) anyway, When i use a canvas to draw a circle exactly on the circle path with this code: Code: dim cek as point cek.X=CircleCenter.x cek.Y=CircleCenter.y cv.DrawCircle(cek.X,cek.Y,150,Colors.Black,False,1) cv.Refresh Now, the spinning circle has to spin just above the circle created with the canvas because their center is same and their radius is same but they are not. Am i doing stg wrong or ? You can check the example. TY Upvote 0
narek adonts said: see attached project. It use CAAnimation to be more smooth that the one with the timer. Narek Click to expand... I have made a small change on the code ( added a panel and initialized the circle on the new panel. btw i dont know why but i had to change the left and top values while adding the circle to panel to a minus otherwise there are 2 circles ,1 is staying at its posiion and other one is circling . you can try it by changing the : paneloyun.AddView(pnlCircle,-100,-50,20,20)to its actual positions on your code) anyway, When i use a canvas to draw a circle exactly on the circle path with this code: Code: dim cek as point cek.X=CircleCenter.x cek.Y=CircleCenter.y cv.DrawCircle(cek.X,cek.Y,150,Colors.Black,False,1) cv.Refresh Now, the spinning circle has to spin just above the circle created with the canvas because their center is same and their radius is same but they are not. Am i doing stg wrong or ? You can check the example. TY
narek adonts Well-Known Member Licensed User Longtime User Aug 15, 2015 #11 upload the project please Upvote 0
tufanv Expert Licensed User Longtime User Aug 15, 2015 #12 sorry fogot it. Attached now Attachments project.zip project.zip 3.4 KB · Views: 373 Upvote 0
narek adonts Well-Known Member Licensed User Longtime User Aug 16, 2015 #13 you should not initialize canvas in application_start event. put cv.Initialize(paneloyun) in Page_resize event Upvote 0
you should not initialize canvas in application_start event. put cv.Initialize(paneloyun) in Page_resize event
tufanv Expert Licensed User Longtime User Aug 16, 2015 #14 narek adonts said: you should not initialize canvas in application_start event. put cv.Initialize(paneloyun) in Page_resize event Click to expand... Yes ! Thank you very much for all your help ! Upvote 0
narek adonts said: you should not initialize canvas in application_start event. put cv.Initialize(paneloyun) in Page_resize event Click to expand... Yes ! Thank you very much for all your help !
tufanv Expert Licensed User Longtime User Aug 17, 2015 #15 narek adonts said: you should not initialize canvas in application_start event. put cv.Initialize(paneloyun) in Page_resize event Click to expand... Dear Narek I have one last question for you. I can't get the top,left values of the rotating circle with a timer. It always shows the top,left values of the initialized values. While it is moving i cant get the coordinates of current position via log(pnlcircle.top) for example. Is there any way i can get it ? Upvote 0
narek adonts said: you should not initialize canvas in application_start event. put cv.Initialize(paneloyun) in Page_resize event Click to expand... Dear Narek I have one last question for you. I can't get the top,left values of the rotating circle with a timer. It always shows the top,left values of the initialized values. While it is moving i cant get the coordinates of current position via log(pnlcircle.top) for example. Is there any way i can get it ?
narek adonts Well-Known Member Licensed User Longtime User Aug 17, 2015 #16 You can not. During any animation the views coordinates are the last coordinates and also you can not click, ... on the view. You need to use a timer for that. I will upload my new class CADisplayLink which is also like a timer but it ticks on each screen Hz refresh. So you will be able to use it as I timer but you will have smooth animations Upvote 0
You can not. During any animation the views coordinates are the last coordinates and also you can not click, ... on the view. You need to use a timer for that. I will upload my new class CADisplayLink which is also like a timer but it ticks on each screen Hz refresh. So you will be able to use it as I timer but you will have smooth animations
tufanv Expert Licensed User Longtime User Aug 17, 2015 #17 narek adonts said: You can not. During any animation the views coordinates are the last coordinates and also you can not click, ... on the view. You need to use a timer for that. I will upload my new class CADisplayLink which is also like a timer but it ticks on each screen Hz refresh. So you will be able to use it as I timer but you will have smooth animations Click to expand... Watiing for it Thank You ! Upvote 0
narek adonts said: You can not. During any animation the views coordinates are the last coordinates and also you can not click, ... on the view. You need to use a timer for that. I will upload my new class CADisplayLink which is also like a timer but it ticks on each screen Hz refresh. So you will be able to use it as I timer but you will have smooth animations Click to expand... Watiing for it Thank You !
narek adonts Well-Known Member Licensed User Longtime User Aug 17, 2015 #18 At the moment you can use this function to retrieve the actual Rect of a view (event during animation). Code: Sub GetCurrentRect (view As View) As Rect Dim no As NativeObject=view no =no.RunMethod("layer",Null).RunMethod("presentationLayer",Null).RunMethod("frame",Null) Dim r As Rect=OBJC.CGRectToRect(no) Return r End Sub You should also update the OBJC module (attached) Narek Attachments OBJC.bas OBJC.bas 1.8 KB · Views: 393 Upvote 0
At the moment you can use this function to retrieve the actual Rect of a view (event during animation). Code: Sub GetCurrentRect (view As View) As Rect Dim no As NativeObject=view no =no.RunMethod("layer",Null).RunMethod("presentationLayer",Null).RunMethod("frame",Null) Dim r As Rect=OBJC.CGRectToRect(no) Return r End Sub You should also update the OBJC module (attached) Narek
tufanv Expert Licensed User Longtime User Aug 17, 2015 #19 Thank you, I have now updated the .bas an added the code to my project. Now do i add under timer_tick getcurrentrect(x) . I tried pnlcircle,panelyoun but they did not work narek adonts said: At the moment you can use this function to retrieve the actual Rect of a view (event during animation). Code: Sub GetCurrentRect (view As View) As Rect Dim no As NativeObject=view no =no.RunMethod("layer",Null).RunMethod("presentationLayer",Null).RunMethod("frame",Null) Dim r As Rect=OBJC.CGRectToRect(no) Return r End Sub You should also update the OBJC module (attached) Narek Click to expand... Upvote 0
Thank you, I have now updated the .bas an added the code to my project. Now do i add under timer_tick getcurrentrect(x) . I tried pnlcircle,panelyoun but they did not work narek adonts said: At the moment you can use this function to retrieve the actual Rect of a view (event during animation). Code: Sub GetCurrentRect (view As View) As Rect Dim no As NativeObject=view no =no.RunMethod("layer",Null).RunMethod("presentationLayer",Null).RunMethod("frame",Null) Dim r As Rect=OBJC.CGRectToRect(no) Return r End Sub You should also update the OBJC module (attached) Narek Click to expand...
narek adonts Well-Known Member Licensed User Longtime User Aug 17, 2015 #20 Is there any error? you should use this way. Code: getcurrentrect(pnlcircle).Left ' forexemple ' or dim r as rect= getcurrentrect(pnlcircle) log(r.Left) Upvote 0
Is there any error? you should use this way. Code: getcurrentrect(pnlcircle).Left ' forexemple ' or dim r as rect= getcurrentrect(pnlcircle) log(r.Left)