I'm not sure, if the velocity was still high enough couldn't it still jump over?
Is it possible to check beforehand if an object is in the path of another object?
-Gan
Yeah, you have to either guarantee that your steps will be small enough to avoid tunneling or start doing sweep collision detection which is much harder.
I actually have an idea for effective and perfect collision. What if I make a line along object 1's path then draw a line perpendicular to it that's the size of object 2. Then if the lines collide they collide. What do you guys think?
I've looked through the sources and they seem quite complex to decipher.
What exactly is the sweep collision test? Googled it and couldn't quite understand.
-Gan
P.S. I'm trying to do 2D and have intersection code for lines and circles.
P.S.S.
Code:
What about making the time out of what velocity the images are travelling at.
I've looked through the sources and they seem quite complex to decipher.
What exactly is the sweep collision test? Googled it and couldn't quite understand.
-Gan
P.S. I'm trying to do 2D and have intersection code for lines and circles.
P.S.S.
Code:
What about making the time out of what velocity the images are travelling at.
Not quite sure what you mean.
I'll try and explain as best I can.
In your iPhone game tutorials you set the xVel and yVel, so you should be able to work out if they've colided by looking at the speeds.
Yeah, I'm thinking the best bet would be to predetermine if they'll collide beforehand by using the velocity mixed in with line intersection of the paths of the object. Then compensate for overlapping collision or complete skips.
I think that's probably the best solution to get the most precise results. Though it's going to be a bit of a doozy to implement.
-Gan
P.S.
Quote:
In your iPhone game tutorials you set the xVel and yVel, so you should be able to work out if they've colided by looking at the speeds.
Wow, that makes me feel good. People are actually watching them...
I think I shall make more tutorials and add more resources. I also need to update the template to have code to detect points of intersection between lines, circles, and polygons. Maybe even image collision code for people who want pixel perfect.
Are you talking about buttons, textboxes, and other such GUI objects? If so, yes. I'll give the exact code when I get back to my mac.
If you aren't, explain a bit on what you wish to remove?
Are you talking about buttons, textboxes, and other such GUI objects? If so, yes. I'll give the exact code when I get back to my mac.
If you aren't, explain a bit on what you wish to remove?
-Gan
Like say I put an image in there, using drawRect and then the Image thing, where do I put my removal code?
Anywhere. Just stop drawing the image. In DrawRect you draw the image 60 times per second. To stop drawing just make it not run the drawImage command:
Global Variable
Code:
BOOL drawImage;
AwakeFromNib
Code:
drawImage = TRUE;
DrawRect
Code:
if (drawImage) {
//Draw image code goes here
}
That way when drawImage is true it draws and doesn't draw when false. So if you wanted the image to disappear when you tap you'd put "drawImage=FALSE;" in TouchBegan or TouchEnded.
Easily code-able. I make a menu like this:
Global Variables
Code:
int currentView;
AwakeFromNib
Code:
currentView = 1;
DrawRect
Code:
if (currentView == 1) {
//Main menu image code here
} else if (currentView == 2) {
//Gameplay screen here
} else if (currentView == 3) {
//Death screen
}
Then in a touched event I'd put this to change:
Code:
if (location.x > # && location.y > # && location.x < # and location.y < #) {
//Simulates a button.
currentView = 2; //Hit play, lets go to the Gameplay screen
}