CreateGameView

76 views
Skip to first unread message

David Johanson

unread,
Jul 10, 2019, 5:15:05 PM7/10/19
to DroidScript
Hello,

Just a question about the new CreateGameView methodology.  I've had a good search but can't really find an answer and I know its early days.etc

From the "Main" script that sets up the app  ...

function OnStart()
{
....
    glview = app.CreateGameView( 1, 1);
    glview.SetFile( "Asteroids.js");
...
}

I cannot get the methods in the child script Asteroids.js (OnLoad) to access the app object or anything defined in the parent script OnStart method (e.g. a layout object ).

Is this correct or is there someway of defining or passing the objects to the Asteroids.js file ?


Many thanks
DJ


Symbroson

unread,
Jul 10, 2019, 5:47:53 PM7/10/19
to DroidScript
The GameView runs on a whole other engine and is not supposed to use app functions. Therefore it is also not directly connected to the main app. However if you really need to you can execute code from the GameView in your main app using the gfx.AppExec method, and vice versa using the gmv.Execute method.

You can think of the GameView like a container with your script - just like a WebView - it has a similar system with app.Execute and web.Execute.

But just that you know - you don't necessarily need to create a main script which creates the game view and loads the script in it - you can also just enable cfg.Game flag and your main script can contain the game code and will immediately run in GameView mode. There are examples of that in the samples section of DroidScript.

David Johanson

unread,
Jul 10, 2019, 6:08:09 PM7/10/19
to DroidScript
Ah - thanks for clearing that up.

I'm basically trying to use the Asteroids example but include a text object that counts the asteroids destroyed.  I was hoping to use a function to just update the text object from within the GameView file.

(I'm teaching a small group of 10yr olds to code with DroidScript but unless the code is game-related they lose interest)

Thanks for you help, much appreciated.

Symbroson

unread,
Jul 10, 2019, 6:17:46 PM7/10/19
to DroidScript
Bitmap fonts are already supported in the latest DS release. Check out this post: https://groups.google.com/forum/#!topic/androidscript/KjIihyPIFqg
Reply all
Reply to author
Forward
0 new messages