A few questions

legendofjon

Member
Licensed User
Longtime User
First of all, I would like to take the time and thank everyone for helping out the noobs like me. I spent a considerable amount of time browsing through the forum and reading past issues that were resolved.

Now i only know python and partially, and for that reason adapting myself to basic4android might take some time. Anyways,

I have many problems:
1) I am trying to set 2 conditions in a If statement
In python i would write
B4X:
If x = 6 or x < 10 #execute the following
Unfortunately, this does not seem to work.
So I tried to do the following instead:
B4X:
If x = 6 Then
      
      Msgbox("something", "title")
      Activity.LoadLayout("level2")
      If L_Points = 10 Then
         
         Msgbox("something", "title")
         Activity.LoadLayout("special")
      End If
   End If
But then what happens is that the second If statements overlaps with the first one. In other words, the second if statements does not execute properly.

2) Random Positions
I have an item, and want it to be placed at random places on the screen, but specified random places. Here's what i mean,
B4X:
   item.Left = Rnd(100, 105) OR Rnd(10, 11)
           item.top = Rnd(0, 10) OR Rnd(15,30)
The first random for left and top shows that it will appear within that area, while the second random for left and top shows it will appear within another area. However, when my app launches it will appear at one of those two area (or more if i add more random).

3)Hide Keyboard
After the user type the number in the box, i want to keyboard to automatically disappear when they click on the submit button, without them having to hit the back button and keyboard will only reappear when they click on the text box again, and disappear once they click on the submit button.

For some reason, the Phone.hidekeyboard suggested by your peers doesn't seem to work for me. I am running on v2.3 and do not seem to have the Phone library (Phone is red and not blue). I do not know how to get Phone to work, or if there's any alternative.

3.5) Adding a timer to type something
Let's say, at a level, i want the user to have only 10 seconds to type something, or else the keyboard disappear and they lose a point. I know how to handle the point system, just that i do not know how to time the keyboard.

4) How do i change the look of the message box?
That is, from the standard look that is based on the user phone design, to a more unique one that will look the same for everyone. For example, message box with blue color as background, or something like that. Later on change the look of the message box to reflect the visual design of the level. Would it be possible to do the same with the keyboard?

5) Changing the color of the text box field
By default, it is white. But lets say i want to change it to something more vibrant like green, would that be possible?

6) What is the code to play music as a background in my app?
I would also use that code to play a different music, at a different level.

I thank in advance everyone who takes the times to try and assist me on many of my problems.
:sign0163:
 

klaus

Expert
Licensed User
Longtime User
You should define two variables as counters for the failing answers.
Each time an answer fails you add one and when the max. allowed wrong answers number is reached you do whatever you want.

For the score look at the Map object.

Best regards.
 
Upvote 0

legendofjon

Member
Licensed User
Longtime User
Good day,

I took your advice, and is working on my quitting and high score system.
ANother issue
now i though of making the numbers that are their to trick the player into thinking its random, dynamic and not static. That is, they would be continuously changing position until the user finds the random number.

In the code below, snb just means static number found at the bottom of the screen. And i am trying to make it do a continuously loop but i receive an error " AN error has occured in sub:
main_play_game_click( B4A line:81)
snb.Left = Rnd (50, 55)
java.lang.NullPointerException
"

B4X:
   snb.Initialize("18")
   Number1 = Rnd(1, 25)
   snb.Text = Number1
   snb.Visible = True
   Do While snb.Visible Then
      If Rnd(0,2) = 0 Then
      snb.Left = Rnd(50, 55)
          snb.top = Rnd(14,140)
      End If
   Loop

Best regard:sign0188:
 
Upvote 0
Top