Pirata Nervo
NervOS Developer
Posts: 699.4765 Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
|
Visual Basic, omg
Ok I'm making a program that has 3 games, everything is ok, it's in portuguese, so i will translate from PT to EN
in this game, I've 3 images: jessica_mini, mensagem and mensagem2
in this game, I've 1 label: mensagens_lidas_label, it shows the number of messages taken by the player
mensagem means message
this isn't working:
Dim showMS1 As Integer
Dim showMS2 As Integer
Dim mensagens_lidas As Integer
mensagens_lidas = 0
showMS1 = 1
showMS2 = 1
If showMS1 = 1 Then
If jessica_mini.Bounds.IntersectsWith(mensagem.Bounds) Then
MsgBox("la la la")
mensagem.Hide()
mensagens_lidas = mensagens_lidas + 1
mensagens_lidas_label.Text = mensagens_lidas
showMS1 = 0
End If
End If
If showMS2 = 1 Then
If jessica_mini.Bounds.IntersectsWith(mensagem2.Bounds) Then
MsgBox("la la la")
mensagem2.Hide()
mensagens_lidas = mensagens_lidas + 1
mensagens_lidas_label.Text = mensagens_lidas
showMS2 = 0
End If
End If
what that should do is:
when the player(jessica_mini) touches the mensagem image, a message box appears » working
when the player(jessica_mini) touches the mensagem2 image, a message box appears » working
the images (mensagem and mensagem2 hide after being touched » working
the label mensagens_lidas_label shows the number of messages taken by the player » it shows 1 after i take the first message but it doesn't show 2 when i take the 2 messages i don't know why
the action jessica_mini.Bounds.IntersectsWith(mensagem2.Bounds) should just be executed when showMSG2 or showMS1 are iqual to 1, but after i say showMSG1/showMSG2 are iqual to 0, the action, still be executed.
|
|
17/11/2007 04:58 AM |
|
ZiNgA BuRgA
Smart Alternative
Posts: 17,022.2988 Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
|
RE: Visual Basic, omg
I'm guessing the variable mensagens_lidas is declared locally. For all languages (that I know of) local variables loose their value after the function ends. Either declare it as Static, or declare it globally.
(This post was last modified: 17/11/2007 05:58 AM by ZiNgA BuRgA.)
|
|
17/11/2007 05:58 AM |
|
Pirata Nervo
NervOS Developer
Posts: 699.4765 Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
|
RE: Visual Basic, omg
the variable is declared as static, it isn't on that copy pasted code.
EDIT, mensagens_lidas means read_messages
i fixed this problem:
Quote:the action jessica_mini.Bounds.IntersectsWith(mensagem2.Bounds) should just be executed when showMSG2 or showMS1 are iqual to 1, but after i say showMSG1/showMSG2 are iqual to 0, the action, still be executed.
i just need to fix the label problem, it shows 1 and doesn't change from one after i take the other message... =|
(This post was last modified: 17/11/2007 12:34 PM by Pirata Nervo.)
|
|
17/11/2007 11:59 AM |
|
Pirata Nervo
NervOS Developer
Posts: 699.4765 Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
|
RE: Visual Basic, omg
but i can't set values outside the function =|
as i said, i already fixed that problem.
i need help with the label now.
EDIT, fixed!
(This post was last modified: 18/11/2007 02:47 AM by Pirata Nervo.)
|
|
18/11/2007 02:44 AM |
|
Pirata Nervo
NervOS Developer
Posts: 699.4765 Threads: 39
Joined: 20th Jun 2007
Reputation: -0.79225
E-Pigs: 19.2466
|
RE: Visual Basic, omg
This is my code now:
before: (and something that i can't remember what i changed.)
|
|
18/11/2007 07:18 AM |
|