3.0.0 beta (ZGE on Android)

Information and change log about the latest ZGameEditor release.

Moderator: Moderators

Post Reply
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi, I wanted to understand how touches are numbered (in order to achieve smooth camera rotation) and for this purpose created small testing application, see the attachment.

Try the following scenario:
1. Touch with finger #1 - appears "0(0)".
2. Touch with finger #2 - appears "1(1)"
3. Untouch finger #1 - problem: "0(0)" jumps to position -1,1 and cannot be further moved.

Am I doing some mistake, or it is just behavior of my device? Is touchGetID() function really necessary, does not it always return the same number as its parameter?
Attachments
TouchIdent.zgeproj
testing application
(4.08 KiB) Downloaded 735 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,
Rado1 wrote:Am I doing some mistake, or it is just behavior of my device?
Sounds like somehow ACTION_POINTER_UP was never called / processed ( perhaps something is wrong in the Java wrapper ). What happens when you put down a finger after the 3 steps you mentioned? A sloppy but quick fix would be to filter out any points with both coordinates equal to 1 or -1.
Rado1 wrote:Is touchGetID() function really necessary, does not it always return the same number as its parameter?
Yes it's necessary, and yes the number will / should stay the same during the lifetime of a touch-event.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

HI Kjell,
Kjell wrote:What happens when you put down a finger after the 3 steps you mentioned again?
An interesting thing happens after touching finger #1 again: it shows "1(0)" and the finger #2 shows "0(1)", both on correct positions. Now I see touchGetID() is really necessary.
Kjell wrote:A sloppy but quick fix would be to filter out any points with both coordinates equal to 1 or -1.
This is not a good solution, I would like to have it fixed in ZGE.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

There is a problem with the code:

int id = touchGetID(Loop.Iteration);
Pos.X = touchGetX(id);
Pos.Y = touchGetY(id);

You pass id to touchGetX/Y. This is not correct. The touch functions all take a touchindex parameter which always should be less than the value touchGetCount() returns.

When you get strange values such as -1 or 1 in getX/Y it is because you are calling with a invalid touchindex (there is no error checking in those functions so it returns invalid coordinates).

You should do:

int id = touchGetID(Loop.Iteration);
Pos.X = touchGetX(Loop.Iteration);
Pos.Y = touchGetY(Loop.Iteration);

These functions are pretty much copied straight from the Android SDK. Here is an article that explains more: http://android-developers.blogspot.se/2 ... touch.html

Edit: nice new avatar Kjell :)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi guys,
VilleK wrote:There is a problem with the code
Whoops .. did not actually download / check / tried Rado1's example .. apparently should have though (^.^);

+ I actually like how you've handled the different touch events through the pressure argument :)

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thanks Ville for explanation, I misunderstood usage of touch IDs. BTW adding functions for touch size and pressure is relatively simple, isn't it?
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Yes adding functions for size and pressure should be easy. Btw, anyone here got a Windows 8 with touchscreen computer yet? We should implement the touch functions for Windows platform too, they just return 0 at the moment.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

VilleK wrote:Btw, anyone here got a Windows 8 with touchscreen computer yet? We should implement the touch functions for Windows platform too, they just return 0 at the moment.
We have Surface with Windows RT tablets in my work, but they have ARM processors. We are waiting for Surface with Windows 8 Pro or for notebooks with touchscreens.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Beta updated today:

- Android: expressions can now detect and override the back-button. If you clear the App.EscapeToQuit setting you can control when the app exits using the quit() function (just like on Windows).
- Android: expressions can now act upon when the app is paused (home button pressed) and resumed. This is a good place to play/pause any music. Note that the Resume action is also called when app is initially started and Pause when it exits.

The actions can be catched with the KeyPress component like this:

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Group Name="#">
  <Children>
    <KeyPress Comment="Pause" CharCode="255">
      <OnPressed>
        <ZExpression Expression="trace("ZGE Activity Paused");"/>
      </OnPressed>
    </KeyPress>
    <KeyPress Comment="Resume" CharCode="254">
      <OnPressed>
        <ZExpression Expression="trace("ZGE Activity Resumed");"/>
      </OnPressed>
    </KeyPress>
    <KeyPress Comment="Back" CharCode="253">
      <OnPressed>
        <ZExpression>
          <Expression>
<![CDATA[trace("ZGE Back key pressed");]]>
          </Expression>
        </ZExpression>
      </OnPressed>
    </KeyPress>
  </Children>
</Group> <!-- # -->

See attached project that demonstrates this. It writes messages to the log when the back button is pressed and when the app is losing or receiving focus.

Download here: http://www.zgameeditor.org/files/ZGameEditor_beta.zip

When I know that these new features are working correctly I plan to take the current release out beta. Then we can start a new beta phase for the attempt to support GL ES 2.
Attachments
AndroidBackPauseResume.zgeproj
demo of the new features
(4.49 KiB) Downloaded 690 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,
VilleK wrote:When I know that these new features are working correctly I plan to take the current release out beta.
Any chance of a fix for not being able to access arrays owned by clones before the release? Support for using byte as local variable and return value of functions would make sense too.

+ A keyboard shortcut ( Ctrl+Enter? ) that equivalents pressing the OK button of a ZExpression would be really handy too :)

K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell wrote:Any chance of a fix for not being able to access arrays owned by clones before the release?
Try todays version: http://www.zgameeditor.org/files/ZGameEditor_beta.zip

Let me know if it works.

OK-button when editing expressions has the keyboard shortcut Alt + O.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,
VilleK wrote:Let me know if it works.
It works when accessed from a ZExpression, but not from a function to which the clone has been passed as argument. It throws the following error ..
Defined var mismatch "Array" in model "‹Ã_^[‹å]Ã" must be at position 0 in Definitions-list.
K
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Something is wrong; android apps just crash now. I tried simple ones with no sunvox, thinking it was the .so stuff,. however they open and then just close?
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell: I got that working here. Can you provide an example?

Jph: That must be because I forgot to rebuild the Android runtime after making the changes for Kjell. Please redownload and try again now.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,
VilleK wrote:I got that working here. Can you provide an example?
It's working for me too now :o Couldn't recreate the error either, so not sure what went wrong the first time I tried.

Thanks a bundle though! Now I can finally have multiple skinned characters without having to hard-code array switching ~

K
Post Reply