Closed Need help with b4I project

John Sturt

Active Member
Licensed User
Longtime User
Hello
I am converting a b4A app to B4I and am stuck on this.

i need to be able to update the screen after every
change to the Grid array variable and the corresponding gridlabel color made
by the code.
This is some demonstration code to show the problem i am having.

If you have a solution then please tell me and what you would like for it.

Many Thanks
John



B4X:
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   
   Dim Grid(10,10) As Int
   Dim GridLabel (10*10) As Label
   Dim Xsize,Ysize As Float
   Dim XPlay,YPlay As Int
   
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   NavControl.ShowPage(Page1)
   
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   Xsize = 100%x / 10
   Ysize = 100%y / 10
   
   Dim Index As Int
   
   For x=0 To 10-1
   For y=0 To 10-1
     Index = x+(y*9)
     GridLabel(Index).Initialize ("LabelEvent")
     GridLabel(Index).Text = "Label "&Index
     GridLabel(Index).Tag = Index
     Page1.RootPanel.AddView (GridLabel(Index),x*Xsize,y*Ysize,Xsize,Ysize)
   Next
   Next
   
   
   
   'This loop is to demonstrate a call from code.
   'The display updates at the end of the loop
   'I need it to update after every change to grid array variable.
   
   '
   For k=0 To 10000
   UpdateCell
   Next
   
End Sub

Private Sub Application_Background
   
End Sub

Sub UpdateCell
   XPlay = Rnd(0,10)
   YPlay = Rnd(0,10)
   Grid(XPlay,YPlay) = Colors.RGB(Rnd(0,255),Rnd(0,255),Rnd(0,255))
   GridLabel(XPlay+(YPlay*9)).Color = Grid(XPlay,YPlay)
End Sub
 

sorex

Expert
Licensed User
Longtime User
I have answered this before in your other tread.

It won't work as you hope it would since you went for a freeze loop.
 

John Sturt

Active Member
Licensed User
Longtime User
Hello Sorex and thank you for the previous reply.

The freeze loop and the for next loop in the code above is
only to demonstrate the problem of the screen updating all at once.
The behaviour i am looking for is one that updates the screen
after each and every call to the UpdateCell subroutine.

Any suggestions.
 

sorex

Expert
Licensed User
Longtime User
if you just want to update some cells then it should be no problem and update when the call is done.
 

John Sturt

Active Member
Licensed User
Longtime User
That is the problem i can update one cell when clicking on
a label and the click event is fired.
The code above shows that something is needed but i am at a loss
as to what that is.
I have tried
ISpritekit but that fails on the fact that it does not allow touch events with Voiceover on at the moment.
It is also a lot of code to add for such a simple operation.
I also tried stacking the changes to the grid in a list and letting
a timer event process them at the tick event.
That just waited for the code to finish and then processed the list at once
giving somewhere near what i need but not close enough.

To see the effect i need see the trailer from the link below.
Stones free
 

sorex

Expert
Licensed User
Longtime User
I don't see a ploblem in creating something like that.

the amount of updates is so small it should happen in a flash.

I don't know what the voice over part is what you talk about (don't have sound here)
 

John Sturt

Active Member
Licensed User
Longtime User
Hello Sorex
I agree it should happen with no problems at all but for some reason
does not.
The Voiceover is a accessibility service by Apple for blind and partially sighted people, I have
tried the code with this disabled and it still does not work.
I am looking for a asynchronous method of processing sound fx,mp3s and updating the screen as well as handling TTS and Voiceover
calls. This sounds a lot but b4A handles it with no problems at all.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…