locked
Layering? RRS feed

  • Question

  • Can some one explain Layering to me? I mean how to use it/what the trick is in Vb. I assume you must use a image and not a picture box. So whats the general concept behind layering for Vb? Trying to learn more about game construction and layering comes up a lot in topics.
    Monday, November 12, 2012 9:21 PM

Answers

  • Layering works exactly as you would expect - if a foreground image with some transparency is painted over a background image, then the areas of transparency in the foreground image  allow portions of the background to show through to the extent that the foreground image is transparent.   There's no magic or difficulty to it.  But your description is really confused.

    For instance: "I have no idea how to create a background that moves and its still transparent"  The background is not transparent.  If it had transparency it would not be a background because whatever is behind it would show through. It's the images that you paint on the background that might have transparent portions, to allow the background to show through

    "but images are limited on functions"  It's the other way around.  If you use pictureboxes you are limited to the functionality that the picture box provides.  If you use images directly you can do anything that is available in GDI.

    "If so how do you use a image instead of a picture? I mean how do you add a picture box to the form?" If you are using images directly you do not add a picture box to the form! How you 'use' the image depends on what you are trying to do with it, but in general you just paint it to the form with DrawImage. Like I said - there's nothing magical.  Paint a image with a portion that is transparent and whatever you paint over shows through the transparent bit.

    • Proposed as answer by Frank L. Smith Tuesday, November 13, 2012 8:52 PM
    • Marked as answer by mholmes_3038 Tuesday, November 13, 2012 9:13 PM
    Tuesday, November 13, 2012 8:42 PM
  • I found this great set of videos on Youtube by VBGameMaker. Highly recommend people check it out if your like me and had problems understanding the basics of GDI. He's making a tile map engine in VB and it appears to output the code in a txt document. He has a few tuts as well which show you how to build a basic tile map and rotate a image. Very good stuff.

    Thansk to the guys above as well for helping me too.

    Video:

    http://youtu.be/Pca0WtStFCA

    • Marked as answer by mholmes_3038 Tuesday, November 13, 2012 9:13 PM
    Tuesday, November 13, 2012 9:13 PM

All replies

  • Hi,

    Layering is a word with many meanings in programming and in image techniques.

    For instance: 

    Layering in OOP is often used to describe the layers of a solution. A solution is therefore made with many projects which are laid over each other.

    Layers in imaging are frames which are placed over each other with transparant parts. AFAIK had GDI always some problems with that. In XAML (WPF/Silverlight) it is implemented for Gif and PNG.


    Success
    Cor

    Tuesday, November 13, 2012 8:29 AM
  • Oh sorry did not even think about that, I'm referring to to layering images on a background or canvas. Basically I want to create a side scroller game. I have everything working except the background. I have no idea how to create a background that moves and its still transparent for the player so the players background matches the background moving. I read that using a image instead of picture box would allow true transparency but images are limited on functions.

    So I guess the first question is, is that true? If so how do you use a image instead of a picture? I mean how do you add a picture box to the form? Just create it? Next question, how does layering work? I assume they setup an array(x,y,Layer) but how do you use it? Ive searched high and low for VB related material but nothing pops up on Google search. I know Vb is not commonly used for game creation but still I would think layering would be something people have discussed and would be useful in things other than just games. Anyway, any information you have about layering images would be great. Thank you.

    Tuesday, November 13, 2012 4:50 PM
  • Layering works exactly as you would expect - if a foreground image with some transparency is painted over a background image, then the areas of transparency in the foreground image  allow portions of the background to show through to the extent that the foreground image is transparent.   There's no magic or difficulty to it.  But your description is really confused.

    For instance: "I have no idea how to create a background that moves and its still transparent"  The background is not transparent.  If it had transparency it would not be a background because whatever is behind it would show through. It's the images that you paint on the background that might have transparent portions, to allow the background to show through

    "but images are limited on functions"  It's the other way around.  If you use pictureboxes you are limited to the functionality that the picture box provides.  If you use images directly you can do anything that is available in GDI.

    "If so how do you use a image instead of a picture? I mean how do you add a picture box to the form?" If you are using images directly you do not add a picture box to the form! How you 'use' the image depends on what you are trying to do with it, but in general you just paint it to the form with DrawImage. Like I said - there's nothing magical.  Paint a image with a portion that is transparent and whatever you paint over shows through the transparent bit.

    • Proposed as answer by Frank L. Smith Tuesday, November 13, 2012 8:52 PM
    • Marked as answer by mholmes_3038 Tuesday, November 13, 2012 9:13 PM
    Tuesday, November 13, 2012 8:42 PM
  • I found this great set of videos on Youtube by VBGameMaker. Highly recommend people check it out if your like me and had problems understanding the basics of GDI. He's making a tile map engine in VB and it appears to output the code in a txt document. He has a few tuts as well which show you how to build a basic tile map and rotate a image. Very good stuff.

    Thansk to the guys above as well for helping me too.

    Video:

    http://youtu.be/Pca0WtStFCA

    • Marked as answer by mholmes_3038 Tuesday, November 13, 2012 9:13 PM
    Tuesday, November 13, 2012 9:13 PM
  • If he's making a tile map engine then the layers he refers to are probably not image layers.  They are likely logical layers in the game play, such as the tile layer, the objects layer, the player layer and so on.  While there is some relationship between the game layer and the image used to represent it, they are very different things. You need to be careful about what exactly you are referring to as a 'layer'.
    • Proposed as answer by Cor Ligthert Tuesday, November 13, 2012 11:29 PM
    Tuesday, November 13, 2012 10:41 PM
  •  How you 'use' the image depends on what you are trying to do with it, but in general you just paint it to the form with DrawImage. 

    Is DrawImage in the Toolbox?  Is it a right click command?  I'm not seeing it in 2013 VB.
    Wednesday, January 14, 2015 12:19 AM
  • Is DrawImage in the Toolbox?  Is it a right click command?  I'm not seeing it in 2013 VB.

    Drawimage is a method of the Graphics object. 

    http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawimage(v=vs.110).aspx

    You use a graphics object to do the drawing, because it supports all the required methods and properties.  Depending on what you are drawing on, the graphics object might be provided to you or it might need to be created.

    You should always create a new thread for a new question.

    Wednesday, January 14, 2015 12:41 AM