Creating a 2D world in QT with bitmap
-
Hi guys,
I'm searching for how to put two images above eachother and then make a part of the foreground image transparant so that it is like a hole and you see the second image? Because I want to use this for my worms game if you shoot in the map that a part of the map is gone like a hole and you see the background image?
I already got this:
@#include <QApplication>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsView>int main( int argc, char **argv )
{
QApplication app(argc, argv);QGraphicsScene scene;
scene.setSceneRect( -100.0, -100.0, 500.0, 500.0 );QGraphicsView view( &scene );
view.setRenderHints( QPainter::Antialiasing );
QGraphicsPixmapItem item(QPixmap(":/images/test1.jpg"));
QGraphicsPixmapItem item2(QPixmap(":/images/test2.jpg"));scene.addItem(&item2);
scene.addItem(&item);view.show();
return app.exec();
}@But I don't know how to make a part of it transparant? I tried with alpha and setmask but doens't work.
Kind regards,
-
-
Oké, but then we still need to show only the thing that is destroyed so we still need to see what is destroyed? That isn't possible if we just paste it over the other image because then if there is something small there is always a big crater over the whole place...
But thanks for your help already :-)
-
If you are having interactions with entities, than it isn't background any more.
Have background completely separate ( for example sky).
Land and other entities are then shown over background.
Than, if you need to delete part of land, you only calculate are the effect, create new image, and copy that part of background onto the newly created image. Again, you show the image over land.
You can also use polygons, for better collision detection etc.Or you could also resize the image of an crater and show it again :).