Texture2D cropping && Array checking

Started by
2 comments, last by Tosh777 13 years, 1 month ago
[font="arial, sans-serif"]
I current have an array of 45 enemies..
These enemies are drawn , animated , updated and what have you. When the enemies health = 0 , it dies...

So

if (aEnemy.enemyHealth <= 0) // if enemy health is equal or below 0 kill the enemy
{
aEnemy.enemyAlive = false;
}




The enemy is drawn when this value is true and when false , it dies..

Now how would i check that every enemy is the array has the value of false...
The reason i want to do this is because i want to check the player has killed all the enemies before progressing to the next wave..

As for texture2d clipping... how can i do it?
I have a health bar implemented and it strechs up and down (using a rectangle) depending on the players health..
Rather than stretching it up and down i wish to clip the image or 'crop' the texture...

Ive tried this draw method overload
spriteBatch.Draw(FullSpeedo, new Rectangle(770, 600, FullSpeedo.Width, FullSpeedo.Height), new Rectangle(770, 600, FullSpeedo.Width / 5, FullSpeedo.Height), Color.White);

But it doesnt do anything...

Ive also looked at the scissorrect? but i dont quite understand how to properly use it .
If you could help it would be good!
[/font]
Advertisement
1.You will just go over all the enemies in the array with for/while or whatever and if any of them is still alive set one bool variable to false. And if all are dead set it to true.
If the variable is true progress to next wave. Is that what you've asked?

2.As for the second question it is not very clear what exaclty you want. Currently you got texture for healthbar or color?
Also why strectches up and down and not reducing the width of the rectangle, thus the width of the texture will be reduced.
In my game in onUpdate i reduce the widht of the healthbar rectangle and achieve this.
If still got problem some screenshots will be appreciated.

1.You will just go over all the enemies in the array with for/while or whatever and if any of them is still alive set one bool variable to false. And if all are dead set it to true.
If the variable is true progress to next wave. Is that what you've asked?

2.As for the second question it is not very clear what exaclty you want. Currently you got texture for healthbar or color?
Also why strectches up and down and not reducing the width of the rectangle, thus the width of the texture will be reduced.
In my game in onUpdate i reduce the widht of the healthbar rectangle and achieve this.
If still got problem some screenshots will be appreciated.


Okay my texture is a 'speedo' dial ...
I wish to crop it down so only 'one green' bar is shown .
Instead it shrinks it down like so -

merog.jpg

Uploaded with ImageShack.us

Once i know how to do it once . I could do it to my health too.

shrinking down the rectangle's width does not crop my texture , it shrinks it to fit...

I do not want this!

hmm i guess this is from xna, because in pure directx works just fine.
I can try tomorrow to crop one texture with xna and will tell you if i achieved something.

This topic is closed to new replies.

Advertisement