Gamewindow background not showing

Discussion in 'Questions (Windows Mobile)' started by enonod, Jun 25, 2009.

  1. enonod

    enonod Well-Known Member Licensed User

    I am having a little trouble putting a background image on a gamewindow.
    I have added the gw object and no errors occur but neither does an image.
    The image is in the same directory. It worked on an Image component.

    Code:
    Form1.Show
       gw.New1(
    "Form1",0,0,321,321)
       gw.DrawBackgroundImage(AppPath & 
    "\grid 20x20.png")
    I am having trouble adjusting from Delphi. I am unsure of the significance between adding an object from the IDE Tools Add Object menu, adding the DLL of the same name via the Tools Component menu etc.

    Some help here please.
     
  2. derez

    derez Expert Licensed User

    I tried to use png in my game program and it works, however I had another case in which png format created problems,
    Try to convert the image to jpg and see if it makes a difference.
     
  3. enonod

    enonod Well-Known Member Licensed User

    Thanks for the suggestion derez. I have now tried jpg and bmp but the image does not show. I must have missed a step but cannot find what. I used the 'Sprite' example to derive this test and used the same steps but there may be something hidden that is not in the actual code.
     
  4. agraham

    agraham Expert Licensed User

    This is the minimum needed to display a background.
    Code:
    Sub App_Start
       Form1.Show
       gw.New1(
    "Form1",0,0,240,320)
       gw.DrawBackgroundImage(AppPath & 
    "\grid 20x20.png")
       
    doevents
       gw.tick
    End Sub
    You need "gw.tick" to force a redraw. Normally this would be in a timer. In this case as "gw.tick" is in App_Start the doevents is essential. I think this is because without it the Form doesn't actually get to draw itself until App_Start exits and then the normal Form drawing seems to take place after the game window drawing leaving a blank form. Having a doevents lets the Form do its' initial drawing and then "gw.tick" can do its' thing.
     
  5. enonod

    enonod Well-Known Member Licensed User

    Thank you very much agraham.
    I think most problems I have are to do with understanding the cycle or sequence of things in B4PPC and what is essential. Is there somewhere that I could have found that information had I followed the right path?

    [Edit] My interpretation of this situation is that I didn't actually go far enough by trying to see each stage happen as I code it.
     
    Last edited: Jun 26, 2009
  6. agraham

    agraham Expert Licensed User

    Not directly. You need some knowledge of how Windows apps, which are event driven, are structured and the role of messages and the applications' message loop to understand how things interact to explain things like this.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice