3.0.0 beta (ZGE on Android)
Moderator: Moderators
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?
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 990 times
Hi Rado1,
K
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:Am I doing some mistake, or it is just behavior of my device?
Yes it's necessary, and yes the number will / should stay the same during the lifetime of a touch-event.Rado1 wrote:Is touchGetID() function really necessary, does not it always return the same number as its parameter?
K
HI Kjell,
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:What happens when you put down a finger after the 3 steps you mentioned again?
This is not a good solution, I would like to have it fixed in ZGE.Kjell wrote:A sloppy but quick fix would be to filter out any points with both coordinates equal to 1 or -1.
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
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

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.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.
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:
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.
- 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> <!-- # -->
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 943 times
Hej Ville,
+ A keyboard shortcut ( Ctrl+Enter? ) that equivalents pressing the OK button of a ZExpression would be really handy too
K
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.VilleK wrote:When I know that these new features are working correctly I plan to take the current release out beta.
+ A keyboard shortcut ( Ctrl+Enter? ) that equivalents pressing the OK button of a ZExpression would be really handy too

K
Try todays version: http://www.zgameeditor.org/files/ZGameEditor_beta.zipKjell wrote:Any chance of a fix for not being able to access arrays owned by clones before the release?
Let me know if it works.
OK-button when editing expressions has the keyboard shortcut Alt + O.
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
Hej Ville,
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
It's working for me too nowVilleK wrote:I got that working here. Can you provide an example?

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