-
Jul 31st, 2009, 05:07 PM
#1
Thread Starter
Member
Help with returning values in another class
Hi, I'm making this game where there is an enemy that goes to the center of the form and grabs an object and brings it back to the side. I made a new class called enemy that makes the enemy. in the class there is a sub called start which the enemy goes to the center and brings the object back. when the enemy comes back with the object i want the integer lives to subtract 1 from it. so i put the code:
Code:
If Not Rect.IntersectsWith(Form1.ClientRectangle) Then
Form1.Lives -= 1
End If
where Rect is the enemy's bounds. when ever rect is not intersecting with the forms bounds (which means when its off screen) lives should subtract 1, but it doesnt.
Please help
-
Jul 31st, 2009, 06:38 PM
#2
Re: Help with returning values in another class
I think that never happens how do you draw something outside a form?
The best way i think that is checking if the rect in the left side the left property is equal to zero or in the right the left property it's equal to the width minus the rect width.
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Jul 31st, 2009, 09:45 PM
#3
Thread Starter
Member
Re: Help with returning values in another class
I'll try it when I get on a computer, but it's weird because when I set other Boolean values from true to false they change but this one just doesn't change. Thanks for your help I'll reply once I try it.
-
Jul 31st, 2009, 10:13 PM
#4
Hyperactive Member
Re: Help with returning values in another class
I would like to see your program when you are done working on it, I am interested in what you are doing.
[COLOR="Black"]
-
Aug 1st, 2009, 01:52 PM
#5
Thread Starter
Member
Re: Help with returning values in another class
OK, Here is the original code:
Code:
If Not Rect.IntersectsWith(Form1.ClientRectangle) Then
Form1.Lives -= 1
_HasEnergy = False
_IsMoving = False
_EnergyIndex = -1
Exit Do
Exit Sub
End If
Here is the changed code:
Code:
If Rect.Right <= 0 Or Rect.Left > Form1.ClientSize.Width Or Rect.Bottom <= 0 Or Rect.Top >= Form1.ClientSize.Height Then
Form1.Lives -= 1
_HasEnergy = False
_IsMoving = False
_EnergyIndex = -1
Exit Do
Exit Sub
End If
I tried it out and it didn't work.
I will post my project when i change the file locations it uses.
Last edited by Giver; Aug 1st, 2009 at 02:42 PM.
-
Aug 1st, 2009, 08:17 PM
#6
Thread Starter
Member
Re: Help with returning values in another class
Does anyone have an idea of how i could resolve my problem?
Tags for this Thread
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
|