Forum Replies Created
-
AuthorPosts
-
Mark.
Thanks you, this helps a lot. I will test it.
Thanks Deffrenzy,
I got the same results on iPhone and Android.
I never heard about these Windows settings ” HighDPI and Fullscreen” for mobile devices !
Monkey1Method New( title:String="Size test mojo app",width:Int=1364,height:Int=750,flags:WindowFlags=WindowFlags.HighDPI | WindowFlags.Fullscreen)Is there a place in this forum that is specific about iOS and Android?
There is a question that remains, How do I detect the device screen size before I can set the Windows size?
@Hezcore: Thank you for your suggestion I will give it a try.
@Diffrenzy: I want my app to look the same on devices with different resolution. I build my sprite sheets with high resolution images , than based on the screen resolution I scale down the images, so they look the same on all screens. That is how I did in Monkey 1.
I would like to hear from @Planiax, @Diddy and other people how do they handle iOS and Android screen resolution with Monkey 2?
Also some apps I have to detect the screen rotation, I am using the OnMeasure() to detect the orientation change, as it is posted above.
I have spent a lot o time searching this web site and Github to find answers and get my apps going. But I spent more time with trial and error than developing my app.
Playniax,
I was able to do my vertical scrolling with this code.
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950Method OnMouseEvent( event:MouseEvent ) Override' Send mouse events to all gui'mouseWheel= event.WheelIf guiPage=GROUPS'Check for mouseIf Mouse.ButtonDown(MouseButton.Left) Or Mouse.ButtonDown(MouseButton.Right) Or Touch.FingerDown( 0 ) Or Touch.FingerDown( 1 )If Mouse.Y>memY 'Check Mouse DirectionDown()memY=Mouse.Y 'save mouse positionElseUp()memY=Mouse.Y 'save mouse positionEndifEndif' Check for TouchIf Touch.FingerDown( 0 ) 'Or Touch.FingerDown( 1 )If Touch.FingerY(0)>memTY 'Check Mouse DirectionDown()memTY=Touch.FingerY(0)ElseUp()memTY=Touch.FingerY(0)EndifEndif'Check for Mouse Wheel' If mouseWheel.Y=-1' Down()' Elseif mouseWheel.Y=1' Up()' EndifEndifguiLayer[guiPage].SendMouseEvent( event )EndMethod Up()mousetxt="UP:"+Mouse.Y+ " memY:"+memY+ " guiPageY:"+guiLayer[guiPage].Y+ " TouchY:"+ Touch.FingerY(0) + " memTY:" + memTY+" mouseWheel:"+mouseWheel.YPrint mousetxtguiLayer[guiPage].Y-=10'limit the bottom of the guiPage to the window height.If guiLayer[guiPage].Y <=-WINDOW_HEIGHT Then guiLayer[guiPage].Y=-WINDOW_HEIGHTEndMethod Down()mousetxt="Down:"+Mouse.Y+ " memY:"+memY+ " guiPageY:"+guiLayer[guiPage].Y+" TouchY:"+ Touch.FingerY(0) + " memTY:" + memTY+" mouseWheel:"+mouseWheel.YPrint mousetxtguiLayer[guiPage].Y+=10'limit the top guiPage to the top of the windowIf guiLayer[guiPage].Y>=0 Then guiLayer[guiPage].Y=0memY=Mouse.Y 'save mouse positionEndAmon,
There is a simple example in the Monkey2 bananas folder called touchtest.
You can detect more than 2 fingers touching the screen.
Here is the code
Monkey1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField gesturing:BoolField g0:AffineMat3fMethod New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod GestureMatrix:AffineMat3f( p0:Vec2f,p1:Vec2f )Local d:=p1-p0,r:=-ATan2( d.y,d.x ),s:=d.LengthReturn New AffineMat3f().Translate( p0 ).Rotate( r ).Scale( s,s )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()Local gmatrix:=New AffineMat3fIf Not gesturing And Touch.FingerDown( 0 ) And Touch.FingerDown( 1 )'begin gesturingg0=-GestureMatrix( Touch.FingerLocation( 0 ),Touch.FingerLocation( 1 ) )gesturing=TrueEndifIf gesturing And Touch.FingerDown( 0 ) And Touch.FingerDown( 1 )'gesturing...gmatrix=GestureMatrix( Touch.FingerLocation( 0 ),Touch.FingerLocation( 1 ) ) * g0Else If gesturing'end gesturinggesturing=FalseEndifcanvas.PushMatrix()canvas.Matrix=gmatrixFor Local i:=0 Until 8For Local j:=0 Until 8canvas.Color= (i~j)&1 ? Color.Yellow Else Color.Greycanvas.DrawRect( New Recti( i*Width/8,j*Height/8,(i+1)*Width/8,(j+1)*Height/8 ) )NextNextcanvas.PopMatrix()canvas.Color=Color.Whitecanvas.Scale( 2,2 )For Local i:=0 Until 10canvas.DrawText( "Finger "+i+": down="+Int( Touch.FingerDown(i) )+", location="+Touch.FingerLocation(i)+", pressure="+Touch.FingerPressure(i),0,i*canvas.Font.Height )NextEndEndFunction Main()New AppInstanceNew MyWindowApp.Run()EndAmon, you have to set the Handle on every single image you load,
amon,
Make sure you are setting the your character’s Handle to (0,0) , also set the layout of your Window or ScreenManager to letterbox, an gravity to (0,0).
playniax thank you that worked !
Abe_King_,
Here is the link to the project. https://github.com/aroldo/M2P2-MenuTemplate
My issue is with the positioning of the gui components on the screen.
Cocon, but I did not insert any new modules and I can run other pyro 2 without any issue.
therevills, the space in the path is not an issue as I have other projects under the same directory and they compile fine.
I sent an e-mail to playniax support , I am waiting for an answer.
thanks for your reply!
codifies,
I know how to write abstract methods, I would like you to expand on your idea.
cocon,
Like this below:
Monkey1234567891011121314151617181920212223#Import "<std>"Using std..Class Exception Extends ThrowableField message:StringMethod New(message:String)Self.message=messageEndMethod ToString:String() VirtualReturn "Exception: " + messageEndEndFunction Main()TryThrow New Exception("Application Started")Catch err:ExceptionPrint "Execption: " + err.messageEndEndIt works in any platform.
codifies, it is a good suggestion. Can you send me a sample code of what you proposed?
I posted a template here http://monkey2.monkey-x.com/forums/topic/monkey-2-app-template/ with suggestions from Mark and impixi.
Yue,
When I import a module like Pyro 2 into monkey 2 I use:
Monkey1234567891011121314151617'Import mojo Modules#Import "<std>"#Import "<mojo>"'import Pyro 2 modules#Import "<pyro-framework>"#Import "<pyro-gui>"#Import "<pyro-scenegraph>"'Using Monkey ModulesUsing std..Using mojo..' Using Pyro 2 modulesUsing pyro.framework..Using pyro.gui..Using pyro.scenegraph..Check the docs Modules and Applications and Namespaces and Using http://monkey2.monkey-x.com/monkey2-docs/
-
AuthorPosts