Author Topic: How to effectively implement GUI with jPCT-AE?  (Read 4165 times)

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
How to effectively implement GUI with jPCT-AE?
« on: July 31, 2013, 07:32:29 am »
GUI means menu\button\dash board\HP-bar and so on,  they are 2D images in most case.

I have tried 2 methods:
  1, Use Android GUI mechanism: This is simple, but will be slow when the view(s) need to update frequently(send msg to UI-Thread, then measure\layout\draw the View-hierarchy.)

 2, Use FrameBuffer.blit(): Need to code yourself for some special effects, and seems to be not very fast(Maybe I used it in a wrong way).

My question:
  1, Could you explain the implementation of FrameBuffer.blit()? And how fast should it be?

  2, Is there a third way? The performance is the most important factor  to me.

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: How to effectively implement GUI with jPCT-AE?
« Reply #1 on: July 31, 2013, 07:48:31 am »
I have made a racing game, and need update  the dash board frequently, e.g: the current speed of player, the current ranking of player, the current score of player, the current time of race and so on.

I use Android-GUI for this now,  it works fine for static views, but slowly for views which update frequently.  After measuring, the updating of GUI was one of the bottlenecks. I have controlled the rate of updating, but the performance was also not good enough.


« Last Edit: July 31, 2013, 07:52:50 am by kiffa »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: How to effectively implement GUI with jPCT-AE?
« Reply #2 on: July 31, 2013, 08:00:33 am »
Blitting is as fast as it gets and i've never seen any impact on performance when using it. For example in this scene



The dialog window itself consists of several blits and each character of the text is a single blit and i don't see any performance impact from it.

Offline kiffa

  • long
  • ***
  • Posts: 199
    • View Profile
Re: How to effectively implement GUI with jPCT-AE?
« Reply #3 on: July 31, 2013, 08:36:03 am »
Thanks, I will try blit and be back soon.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: How to effectively implement GUI with jPCT-AE?
« Reply #4 on: July 31, 2013, 10:55:19 pm »
Or you can get inspired by my GUI (maybe it will be sometimes for download...) ;)


Offline Yerst

  • byte
  • *
  • Posts: 38
    • View Profile
Re: How to effectively implement GUI with jPCT-AE?
« Reply #5 on: August 03, 2013, 06:17:27 pm »
@Thomas.: What were you using to do this?

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: How to effectively implement GUI with jPCT-AE?
« Reply #6 on: August 03, 2013, 08:23:18 pm »
For graphics part is used only FrameBuffer.blit(...), but control of menu itself is little bit complex. I am used recursive algorithm.