iOS Question X2 game wrong touch action B4I

developer_123

Active Member
Licensed User
Longtime User
Good Day!

This thread come related from this last thread: https://www.b4x.com/android/forum/threads/x2-game-wrong-touch-action.135675/

I installed the last versión of B4i, B4A and B4J, and appear some troubles in the compilation, but testing the TOUCHY example, I can solve that in B4A and B4J, but in B4I is not working. Really, I don't know why, because there is same code inside the designer in three programs (B4X Package) and the same code inside the game module. In B4A and B4J works fine the touch action, but in B4i don´t work, and not appear any error. The behavior in my Iphone only run the program, but not work the touch over the tiled escene. The touch action Works fine Over the normal buttons, but not over the tiled when I want to drag some element. This is only happens in B4I. The next are the codes I implemented:

Firs I include the B4XMainPage Module from "Touchy" example.

INSIDE THE CODE DESIGNER:
B4X:
'All variants script
GameRatio = 1.888 'width / height
ScreenRatio = 100%x / 100%y
If ScreenRatio < GameRatio Then
 ivForeground.SetLeftAndRight(0, 100%x)
 ivForeground.Height = ivForeground.Width / GameRatio
 ivForeground.VerticalCenter = 50%y
Else
 ivForeground.SetTopAndBottom(0, 100%y)
 ivForeground.Width = ivForeground.Height * GameRatio
 ivForeground.HorizontalCenter = 50%x
End If
ivBackground.SetLeftAndRight(ivForeground.Left, ivForeground.Right)
ivBackground.SetTopAndBottom(ivForeground.Top, ivForeground.Bottom)
PanelForTouch.SetLeftAndRight(ivForeground.Left, ivForeground.Right)
PanelForTouch.SetTopAndBottom(ivForeground.Top, ivForeground.Bottom)


INSIDE THE GAME MODULE:
B4X:
#If B4J
Private Sub Panel_Touch (Action As Int, X As Float, Y As Float)
    'Multitouch.B4JDelegateTouchEvent(Sender, Action, X, Y)
End Sub
#Else If B4i
Private Sub Panel_Multitouch (Stage As Int, Data As Object)
    Multitouch.B4iDelegateMultitouchEvent(Sender, Stage, Data)
End Sub
#End If

I appreciate any orientation!
 

developer_123

Active Member
Licensed User
Longtime User
Which error?
In the first moment that I opened my project in the latest B4X version, when compiling it did not recognize the multitouch variable and it was evident that it was necessary to include the B4XPages library as well as the B4XMainPage module, and also the designer code and the game module that I related previously. As I already mentioned, when making these adjustments the project compiled without errors. Now the drawback is that using B4I when I open my project on my iphone, it does not respond to touch events on the mosaic area, while in B4A and B4J it works normally. At this moment it is running on iPhone but it does not show any error, it simply does not respond to the touch function. This only happens on the mosaic, because on the buttons that I have added to the application, if it works, touch events respond.

I do not understand why if for the three programs (b4i, b4j, b4a) it is exactly the same code both in the game module, as in the B4XMainPage module and in the designer, it does not work in B4i.

Surely it is missing including some conditional instruction of the type (#If B4i).
 
Last edited:
Upvote 0

developer_123

Active Member
Licensed User
Longtime User
In the first moment that I opened my project in the latest B4X version, when compiling it did not recognize the multitouch variable and it was evident that it was necessary to include the B4XPages library as well as the B4XMainPage module, and also the designer code and the game module that I related previously. As I already mentioned, when making these adjustments the project compiled without errors. Now the drawback is that using B4I when I open my project on my iphone, it does not respond to touch events on the mosaic area, while in B4A and B4J it works normally. At this moment it is running on iPhone but it does not show any error, it simply does not respond to the touch function. This only happens on the mosaic, because on the buttons that I have added to the application, if it works, touch events respond.

I do not understand why if for the three programs (b4i, b4j, b4a) it is exactly the same code both in the game module, as in the B4XMainPage module and in the designer, it does not work in B4i.

Surely it is missing including some conditional instruction of the type (#If B4i).
Something I just noticed is that the next block is not working to me in B4I

B4X:
Sub PanelForTouch_Touch (Action As Int, X As Float, Y As Float)

Select Action
Case PanelForTouch.TOUCH_ACTION_DOWN
'Any instruction....

Case PanelForTouch.TOUCH_ACTION_MOVE
'Any instruction....

Case PanelForTouch.TOUCH_ACTION_UP
'Any instruction....

end select

I see in the touchy example that these events are used with the properties of the variable "multitouch". I will have to modify my source code to adapt it to variables of the type X2MultiTouch
 
Upvote 0
Top