Tag Info

New answers tagged


You can use only the distance, without use the sqrt and the Pow because the distance is usually calculate with this formula: float dist(vector3d v1, v2) { v.x = v1.x - v2.x; v.y = v1.y - v2.y; v.z = v1.z - v2.z; return sqrt(v.x*v.x + v.y*v.y + v.z*v.z); } as you can see here.


Yeah, this is how spritebatch is meant to be used. It takes a view matrix in the begin parameter and uses that throughout the begin/end pair. You could argue that spritebatch would be more flexible with matrices if you could pass a view matrix in for each .draw call, but evidently the XNA team decided against this for one reason or another. To answer your ...


To add a bit to Rokk's answer. Chances are, since you say you are new to XNA, that you use the GameComponentList, in the Game class, known as Components. If so, then the solution is simple. Just make sure you can reach that Components list from your collision code and use Components.Remove(healthPickup);. Your game will now stop drawing it and the garbage ...


If you have a list of entities or a list of potions which you loop through, you can simply remove the entity from the list. This should be standard practice anyway, as this makes it extremely easy to add more items without assigning loads of variables.


If your Health pickup is an object, you could set it to null if you detect a collision. The garbage collector will do the rest for you. But don't try to reference that object after it is null because it will give your a runtime error. if(player.collides(healthpotion)) { player.health += 100; healthpotion = null; }

Top 50 recent answers are included