|
-
Mar 6th, 2009, 01:49 PM
#1
Thread Starter
PowerPoster
[RESOLVED] [VB6]about timers in UC
i'm trying build a game with my Sprite... these game has 2 timers, but sprite control has more 3 timers....
when i use my sprite control, using the Top property, it give me an error: "the object doesn't support these property or method" but when i stop 1 timer(in my object, but the problem is that i need it) these message don't appear.... can anyone advice-me?
thanks
-
Mar 6th, 2009, 04:20 PM
#2
Re: [VB6]about timers in UC
Can you show us the line(s) of code that is generating the error.
-
Mar 6th, 2009, 04:28 PM
#3
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
in game is the 2nd "if":
Code:
Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyP Or KeyCode = vbKeyEscape) Then
frmPausa.Show
End If
If KeyCode = vbKeyUp Then
sprPlayer.Top = sprPlayer.Top - 10
End If
End Sub
in my UC is in timer, because when i desactive the timer the problem got out:
Code:
Private Sub tmrNewEvents_Timer()
Dim I As Integer
Dim Name As String
Dim ctlTemp As Control
Dim L1 As Long
Dim L2 As Long
Dim T1 As Long
Dim T2 As Long
Dim H1 As Long
Dim H2 As Long
Dim W1 As Long
Dim W2 As Long
Dim Direction As Direction
On Error Resume Next
If (blnActivateMoveNotMoveEvents = False And blnJoystickActivate = False) Then tmrNewEvents.Enabled = False
If blnActivateMoveNotMoveEvents = True Then
If (lngOldPosX < Extender.Left And lngOldPosY < Extender.Top) Then
DirDirection = DirectionLeftUp
ElseIf (lngOldPosX < Extender.Left And lngOldPosY > Extender.Top) Then
DirDirection = DirectionLeftDown
ElseIf (lngOldPosX > Extender.Left And lngOldPosY < Extender.Top) Then
DirDirection = DirectionRightUp
ElseIf (lngOldPosX > Extender.Left And lngOldPosY > Extender.Top) Then
DirDirection = DirectionRightDown
ElseIf (lngOldPosX < Extender.Left) Then
DirDirection = DirectionLeft
ElseIf (lngOldPosX > Extender.Left) Then
DirDirection = DirectionRight
ElseIf (lngOldPosY < Extender.Top) Then
DirDirection = DirectionUp
ElseIf (lngOldPosX > Extender.Top) Then
DirDirection = DirectionLeftDown
End If
If Extender.Left <> lngOldPosX Or Extender.Top <> lngOldPosY Then
lngOldPosX = Extender.Left
lngOldPosY = Extender.Top
RaiseEvent Move(lngOldPosX, lngOldPosY, DirDirection)
DoEvents
Name = Extender.Name
If Col.Activate = True Then
L1 = Extender.Left + Col.Left
T1 = Extender.Top + Col.Top
W1 = Col.Width
H1 = Col.Height
Else
L1 = lngOldPosX
T1 = lngOldPosY
W1 = Extender.Width
H1 = Extender.Height
End If
For I = 0 To Extender.Container.Controls.Count - 1
If Extender.Container.Controls(I).Name <> Name Then
If TypeName(Extender.Container.Controls(I)) = "Sprite" Then
If Extender.Container.Controls(I).LimColActivate = True Then
L2 = Extender.Container.Controls(I).Left + Extender.Container.Controls(I).LimColLeft
T2 = Extender.Container.Controls(I).Top + Extender.Container.Controls(I).LimColTop
W2 = Extender.Container.Controls(I).LimColWidth
H2 = Extender.Container.Controls(I).LimColHeight
Else
L2 = Extender.Container.Controls(I).Left
T2 = Extender.Container.Controls(I).Top
W2 = Extender.Container.Controls(I).Width
H2 = Extender.Container.Controls(I).Height
End If
If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
Exit For
DoEvents
End If
Else
L2 = Extender.Container.Controls(I).Left
T2 = Extender.Container.Controls(I).Top
W2 = Extender.Container.Controls(I).Width
H2 = Extender.Container.Controls(I).Height
If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
Exit For
DoEvents
End If
End If
End If
Next I
Else
RaiseEvent NotMove(lngOldPosX, lngOldPosY, DirDirection)
DoEvents
End If
End If
If (blnJoystickActivate = True And StartJoystick(0) = True) Then
Call PollJoystick
If (MYJOYEX.dwXpos = 0 And MYJOYEX.dwYpos = 0) Then
Direction = DirectionLeftUp
ElseIf (MYJOYEX.dwXpos = 0 And MYJOYEX.dwYpos = 65535) Then
Direction = DirectionLeftDown
ElseIf (MYJOYEX.dwXpos = 65535 And MYJOYEX.dwYpos = 0) Then
Direction = DirectionRightUp
ElseIf (MYJOYEX.dwXpos = 65535 And MYJOYEX.dwYpos = 65535) Then
Direction = DirectionRightDown
ElseIf (MYJOYEX.dwXpos = 0) Then
Direction = DirectionLeft
ElseIf (MYJOYEX.dwXpos = 65535) Then
Direction = DirectionRight
ElseIf (MYJOYEX.dwYpos = 0) Then
Direction = DirectionUp
ElseIf (MYJOYEX.dwYpos = 65535) Then
Direction = DirectionDown
Else
Direction = DirectionNone
End If
RaiseEvent Joystick(JoyNum, Direction, lngButton)
DoEvents
End If
End Sub
but in my form teste(where i test these control), i don't recive any error...
-
Mar 7th, 2009, 10:29 AM
#4
Re: [VB6]about timers in UC
Is sprPlayer a control in your uc? Or is sprPlayer a dynamic control that you change during runtime? When you get the error, can you debug.print these and show us the result.
Debug.Print (sprPlayer Is Nothing)
Debug.Print TypeName(sprPlayer)
-
Mar 7th, 2009, 10:40 AM
#5
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
 Originally Posted by LaVolpe
Is sprPlayer a control in your uc? Or is sprPlayer a dynamic control that you change during runtime? When you get the error, can you debug.print these and show us the result.
Debug.Print (sprPlayer Is Nothing)
Debug.Print TypeName(sprPlayer)
the sprPlayer is an instance of my Sprite control.
Debug.Print (sprPlayer Is Nothing)=false
Debug.Print TypeName(sprPlayer)=sprite
-
Mar 7th, 2009, 10:54 AM
#6
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
see you self...
in Sprite folder is where you must compile the Sprite and put it in CatchDiamonds folder...
then test the game CatchDiamonds... use the Up key...
i'm rebuild the entire game, but now just crash
i'm sorry if i give you much work... thanks
Last edited by joaquim; May 29th, 2009 at 04:55 AM.
-
Mar 7th, 2009, 12:31 PM
#7
Re: [VB6]about timers in UC
You might want to update your last posting and include your project also as Zip files. Not everyone uses WinRar.
-
Mar 7th, 2009, 03:38 PM
#8
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
(help me on these 1 zip file is 900Kb's... i have winzip 9... how can i zip the file with 500Kb(for example) by parts?
thanks)
-
Mar 9th, 2009, 12:52 PM
#9
Hyperactive Member
Re: [VB6]about timers in UC
Okay, the problem is not with:
vb Code:
If KeyCode = vbKeyUp Then sprPlayer.Top = sprPlayer.Top - 10 End If
The problem is with the code right before it that you didn't post above. sprPlayer is a picturebox and .Filename is not a valid property of a picturebox. To change the picture in a picturebox, do this:
vb Code:
Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyP Then MsgBox "Pause" End If If KeyCode = vbKeyEscape Then End End If If KeyCode = vbKeyUp Then If blnCollisionUp = True Then If plPlayer = Male Then 'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif" sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif") Else 'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif" sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif") End If Else If plPlayer = Male Then 'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Movement\Up.gif" sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Movement\Up.gif") Else 'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Movement\Up.gif" sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Movement\Up.gif") End If sprPlayer.Top = sprPlayer.Top - 10 End If End If End Sub Private Sub Form_Load() picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif") plPlayer = Male blnCollisionDown = False blnCollisionLeft = False blnCollisionRight = False blnCollisionUp = False picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif") If plPlayer = Male Then 'If sprPlayer.Picture <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif" sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif") Else 'If sprPlayer.Picture <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif" sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif") End If End Sub
To check to see which picture is in the box, you might want to have a variable that is changed every time you load a new picture into the picturebox that will tell you what the last one loaded was.
If you need example code of this, just let me know.
Enjoy.
-
Mar 9th, 2009, 03:53 PM
#10
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
 Originally Posted by deathfxu
Okay, the problem is not with:
vb Code:
If KeyCode = vbKeyUp Then
sprPlayer.Top = sprPlayer.Top - 10
End If
The problem is with the code right before it that you didn't post above. sprPlayer is a picturebox and .Filename is not a valid property of a picturebox. To change the picture in a picturebox, do this:
vb Code:
Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyP Then
MsgBox "Pause"
End If
If KeyCode = vbKeyEscape Then
End
End If
If KeyCode = vbKeyUp Then
If blnCollisionUp = True Then
If plPlayer = Male Then
'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif"
sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif")
Else
'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif"
sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif")
End If
Else
If plPlayer = Male Then
'If sprPlayer.FileName <> App.Path & "\Images\Male Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Movement\Up.gif"
sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Movement\Up.gif")
Else
'If sprPlayer.FileName <> App.Path & "\Images\Female Player\Movement\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Movement\Up.gif"
sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Movement\Up.gif")
End If
sprPlayer.Top = sprPlayer.Top - 10
End If
End If
End Sub
Private Sub Form_Load()
picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif")
plPlayer = Male
blnCollisionDown = False
blnCollisionLeft = False
blnCollisionRight = False
blnCollisionUp = False
picGame.Picture = LoadPicture(App.Path & "\Images\Background\Level1.gif")
If plPlayer = Male Then
'If sprPlayer.Picture <> App.Path & "\Images\Male Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Male Player\Stoped\Up.gif"
sprPlayer.Picture = LoadPicture(App.Path & "\Images\Male Player\Stoped\Up.gif")
Else
'If sprPlayer.Picture <> App.Path & "\Images\Female Player\Stoped\Up.gif" Then sprPlayer.FileName = App.Path & "\Images\Female Player\Stoped\Up.gif"
sprPlayer.Picture = LoadPicture(App.Path & "\Images\Female Player\Stoped\Up.gif")
End If
End Sub
To check to see which picture is in the box, you might want to have a variable that is changed every time you load a new picture into the picturebox that will tell you what the last one loaded was.
If you need example code of this, just let me know.
Enjoy. 
i'm sorry but isn't a picturebox, it's my sprite control you must compile it(is in *.rar files)... i'm sorry about that....
please compile my sprite control then put in game folder, Catch Dimonds, then run it again and test it... i'm sorry and thanks
-
Mar 13th, 2009, 06:02 PM
#11
Hyperactive Member
Re: [VB6]about timers in UC
lol. When I opened the project there was a picturebox of the same name in the middle of the form. Sorry man, i'll rerun it.
-
Mar 13th, 2009, 06:11 PM
#12
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
"lol. When I opened the project there was a picturebox of the same name in the middle of the form."
that's normal, after the error... after you compile my sprite and put it in folder game and run the project and click up key, you will see the error.
try test it putting the MoveNotMove and JoystickActivate true and false(you will see that the error is out)... but i need these properties true.
"Sorry man, i'll rerun it"
that's ok... honestly, thanks for you trying help me
-
Mar 13th, 2009, 06:30 PM
#13
Hyperactive Member
Re: [VB6]about timers in UC
I kept getting an error in the Sprite project when you were trying to set MaskColor to "Null". I changed it to "vbNull", recompiled, ran CatchDiamonds, and when I hit the up key Visual Basic froze, lol.
So this might take a few mins. =P
Edit: "Hard Froze". Like [ctrl]+[pausebreak] didn't even work.
-
Mar 13th, 2009, 06:35 PM
#14
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
 Originally Posted by deathfxu
I kept getting an error in the Sprite project when you were trying to set MaskColor to "Null". I changed it to "vbNull", recompiled, ran CatchDiamonds, and when I hit the up key Visual Basic froze, lol.
So this might take a few mins. =P
Edit: "Hard Froze". Like [ctrl]+[pausebreak] didn't even work.
yes... i test(only know) that error... before it don't give me the error
i'm confuse with these
thanks for help me
-
Mar 13th, 2009, 07:07 PM
#15
Hyperactive Member
Re: [VB6]about timers in UC
Okay, this program is so massive it's taking me a while to trace it through. Do you know why Sprite.ocx is calling the ShowImage sub like 20 times right when it starts up?
-
Mar 13th, 2009, 07:19 PM
#16
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
 Originally Posted by deathfxu
Okay, this program is so massive it's taking me a while to trace it through. Do you know why Sprite.ocx is calling the ShowImage sub like 20 times right when it starts up?
20 times!?!
i think not.... only in some properties...
-
Mar 13th, 2009, 07:23 PM
#17
Hyperactive Member
Re: [VB6]about timers in UC
Never mind. I just realized that every graphics-related Property Let statement recalls it for each time when you are initializing all the values.
-
Mar 13th, 2009, 07:33 PM
#18
Hyperactive Member
Re: [VB6]about timers in UC
In the CatchDiamonds project, the sprPlayer_KeyDown is only getting called the first time you press a key, but neither project is getting stuck in an infinite loop.
Which means something may be disabling the event trigger for it.
Still looking.
-
Mar 13th, 2009, 07:47 PM
#19
Hyperactive Member
Re: [VB6]about timers in UC
FINALLY!!!
Almost 2 hours later.
First change:
vb Code:
Public Property Let FileName(New_FileName As String) Dim I As Integer strFileName = New_FileName tmrAnimation.Enabled = False If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then UserControl.Picture = Nothing UserControl.MaskPicture = Nothing UserControl.MaskColor = Null 'Change this to "vbNull"
Then, the usercontrol Sprite.ocx is losing focus after the first keypress. Into the form and all objects on it in _KeyDown I added:
vb Code:
Call sprPlayer_KeyDown(KeyCode, Shift)
And it worked. If you can't duplicate this, lemme know.
Last edited by deathfxu; Mar 13th, 2009 at 07:57 PM.
-
Mar 13th, 2009, 07:50 PM
#20
Hyperactive Member
Re: [VB6]about timers in UC
Also, to help debugging, I removed your test project "teste", and added frmLevel1 to the project and set it as the startup object. It allowed me to breakpoint both projects at once.
I can walk you through how to do that also if you don't understand what I mean.
-
Mar 14th, 2009, 06:20 AM
#21
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
 Originally Posted by deathfxu
FINALLY!!!
Almost 2 hours later.
First change:
vb Code:
Public Property Let FileName(New_FileName As String)
Dim I As Integer
strFileName = New_FileName
tmrAnimation.Enabled = False
If (Dir(strFileName) = "" Or ValidFile(UCase(strFileName)) = False) Then
UserControl.Picture = Nothing
UserControl.MaskPicture = Nothing
UserControl.MaskColor = Null 'Change this to "vbNull"
Then, the usercontrol Sprite.ocx is losing focus after the first keypress. Into the form and all objects on it in _KeyDown I added:
vb Code:
Call sprPlayer_KeyDown(KeyCode, Shift)
And it worked. If you can't duplicate this, lemme know.
i have 1 question: if the sprPlayer TabIndex property is 0, why it loses the focus?
thanks
-
Mar 14th, 2009, 06:22 AM
#22
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
 Originally Posted by deathfxu
Also, to help debugging, I removed your test project "teste", and added frmLevel1 to the project and set it as the startup object. It allowed me to breakpoint both projects at once.
I can walk you through how to do that also if you don't understand what I mean.
if you have the frmLevel1 in Sprite project, how can you compile the OCX file?
thanks
-
Mar 14th, 2009, 08:39 AM
#23
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
i continue with same problem
i'm trying without sucess
-
Mar 14th, 2009, 09:19 AM
#24
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
i found where is the error, but i don't understand it
Code:
MsgBox "oi"
If Extender.Container.Controls.Count > 1 Then
For I = 0 To Extender.Container.Controls.Count - 1
If Extender.Container.Controls(I).Name <> Name Then
If TypeName(Extender.Container.Controls(I)) = "Sprite" Then
If Extender.Container.Controls(I).LimColActivate = True Then
L2 = Extender.Container.Controls(I).Left + Extender.Container.Controls(I).LimColLeft
T2 = Extender.Container.Controls(I).Top + Extender.Container.Controls(I).LimColTop
W2 = Extender.Container.Controls(I).LimColWidth
H2 = Extender.Container.Controls(I).LimColHeight
Else
L2 = Extender.Container.Controls(I).Left
T2 = Extender.Container.Controls(I).Top
W2 = Extender.Container.Controls(I).Width
H2 = Extender.Container.Controls(I).Height
End If
If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
Exit For
DoEvents
End If
Else
L2 = Extender.Container.Controls(I).Left
T2 = Extender.Container.Controls(I).Top
W2 = Extender.Container.Controls(I).Width
H2 = Extender.Container.Controls(I).Height
If CollisionPrecise(L1, T1, W1, H1, L2, T2, W2, H2) = True Then
RaiseEvent Collision(Extender.Container.Controls(I).Name, IndexControlArray(Extender.Container.Controls(I)), DirDirection)
Exit For
DoEvents
End If
End If
End If
Next I
End If
Else
RaiseEvent NotMove(lngOldPosX, lngOldPosY, DirDirection)
DoEvents
End If
End If
the messagebox is showed, but then is give me an error(i use the messagebox for catch the error )
if i put the messagebox in the If statement, i will recive the error...
what isn't right with these line:
Code:
Extender.Container.Controls.Count > 1
????
error message: "these object doesn't support this property or method"
thanks
-
Mar 15th, 2009, 06:59 PM
#25
Hyperactive Member
Re: [VB6]about timers in UC
 Originally Posted by joaquim
i have 1 question: if the sprPlayer TabIndex property is 0, why it loses the focus?
thanks
No. TabIndex changes the order that controls get focus when you press the [tab] key.
-
Mar 15th, 2009, 07:00 PM
#26
Hyperactive Member
Re: [VB6]about timers in UC
 Originally Posted by joaquim
if you have the frmLevel1 in Sprite project, how can you compile the OCX file?
thanks
I wasn't compiling it, I was just running it straight out of the project.
-
Mar 15th, 2009, 07:09 PM
#27
Hyperactive Member
Re: [VB6]about timers in UC
 Originally Posted by joaquim
i found where is the error, but i don't understand it 
the messagebox is showed, but then is give me an error(i use the messagebox for catch the error  )
if i put the messagebox in the If statement, i will recive the error...
what isn't right with these line:
Code:
Extender.Container.Controls.Count > 1
????
error message: "these object doesn't support this property or method"
thanks
I didn't get any error here. I left the project on my computer in case you had any problems, and I just went back in and ran it with no problems. I'm tempted to just send the files back to you.
Have you been making other changes?
-
Mar 20th, 2009, 04:17 PM
#28
Thread Starter
PowerPoster
Re: [VB6]about timers in UC
"I didn't get any error here. I left the project on my computer in case you had any problems, and I just went back in and ran it with no problems. I'm tempted to just send the files back to you."
i belive you don't get the error, but try compile it and try use it in other project... use any key for move it... here you will see it.
"Have you been making other changes?"
yes...
Code:
UserControl.Parent.Controls.Count
isn't the same but works fine for it is.... but i'm continue testing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|