B4J Question Rotate Application 90 Degress

ElliotHC

Active Member
Licensed User
For ease of coding, I've laid out the App 1080 wide by 1920 tall. (Portrait)

All my references are based on those positions.

Now I need to run the App on a 1920*1080 display so I need to rotate everything to fit the screen, can anyone point me in the right direction?

Thanks
 

ThRuST

Well-Known Member
Licensed User
Longtime User
Any sufficiently advanced technology is indistinguishable from magic

Love that quote :) I haven't tried your magic formula yet, but I'll do that later and let you know if I'm teleported to Coruscant, or not ;)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Ok now I have clicked the "roller-coaster button", it was nice, an upside down experience so to speak, a dizzy experience :confused::)
The new XUI library needs to be explored, so I assume Erel made a tutorial for this that I should watch. Nice example I'll explore it further.

Cheers :)
 
Upvote 0

emexes

Expert
Licensed User
And For Bonus Points, May I Present?...

I added the following code at the end of the AppStart Sub:
B4X:
'...
    MainForm.Show
 
    Dim RootPain As B4XView = MainForm.RootPane
    Do While True
        RootPain.Rotation = Sin(DateTime.Now * 0.0003) * 360
        RootPain.Top = Sin(DateTime.Now * 0.0011) * 200
        RootPain.Left = Sin(DateTime.Now * 0.0017) * 200
        Sleep(15)
    Loop
 
End Sub
and suddenly the previous demo turned into an action video game of "Click That Button".

Use keyboard: Tab moves focus from button to button, Space clicks current button.
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
B4X:
'...
    MainForm.Show
 
    Dim RootPain As B4XView = MainForm.RootPane
    Do While True
        RootPain.SetRotationAnimated(700, Rnd(0, 359))
        RootPain.SetLayoutAnimated(700, Rnd(-200, 200), Rnd(-200, 200), 123, 123)    '123 = no effect
        Sleep(1000)
    Loop
I really need to let this go ;-)
 
Last edited:
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
I'm not sure if this thread is considered solved or not. I have another solution using JavaObject:


B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Main") 'Load the layout file.
    MainForm.Show
    
    RotateNode(MainForm.RootPane, 90)
End Sub

Sub RotateNode(View As JavaObject, Angle As Double)   
    Dim Rot As JavaObject
    Rot.InitializeNewInstance("javafx.scene.transform.Rotate", Null)
    Rot.RunMethod("setAngle", Array(Angle))
    Rot.RunMethod("setPivotX", Array(View.RunMethod("getWidth", Null) /2))
    Rot.RunMethod("setPivotY", Array(View.RunMethod("getHeight", Null) /2))

    Dim Transforms As JavaObject
    Transforms = View.RunMethod("getTransforms", Null)
    Transforms.RunMethod("add", Array(Rot))   
End Sub

You can also change the pivot.
 
Upvote 0
Top