c# - XNA changing blendstate from alpha to Additive -
c# - XNA changing blendstate from alpha to Additive -
here's problem using depth command have different sprites need different blendstates how can alter if started spritebatch.begin(...)
i trying alter spritebatch.graphicsdevice.blendstate doesn't seems working
i cannot turn black area transparency
thank you
still seems cannot save layer order between them using code... guess problem might in using object.draw(spritebatch) , draw within method. think theres problem because have 2 classes each 1 draw method input spritebatch im doing spritebatch.begin(spritesortmode.fronttoback, blendstate.additive); d.drawattack(gametime, spritebatch); spritebatch.end(); spritebatch.begin(spritesortmode.fronttoback, blendstate.alphablend); drawobjects(gametime, spritebatch); charactersdraw(gametime, spritebatch); // same class d.drawattack spritebatch.end(); both draw layer !between both spritebatche! doesn't seems create difference layerdepth works fine characters , draw objects... doesn't work drawattack
you need multiple spritebatch.begin() .. end() calls, each different blendstate. can still preserve layerdepth among them.
for example:
batch.begin(spritesortmode.fronttoback, blendstate.additive); batch.draw(tex1, sprite1, null, color.white, 0.0f, vector2.zero, 1.0f, spriteeffects.none, layer1); batch.draw(tex2, sprite2, null, color.white, 0.0f, vector2.zero, 1.0f, spriteeffects.none, layer2); batch.end(); //new blend state, new begin...end batch.begin(spritesortmode.fronttoback, blendstate.alphablend); batch.draw(tex3, sprite3, null, color.white, 0.0f, vector2.zero, 1.0f, spriteeffects.none, layer3); batch.draw(tex4, sprite4, null, color.white, 0.0f, vector2.zero, 1.0f, spriteeffects.none, layer4); batch.end(); c# xna xna-4.0
Comments
Post a Comment