Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Dec 2004
    Posts
    9

    VTM 5 3 (Adding_Game_Code)

    Sorry if there is somewhere else on the forums but I have been looking here and online and have not found a way to solve this problem.

    Ok I finish the video and tried to run my code but get an error. The error is :

    drawengine.cpp(27) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'wxBitmap *' (or there is no acceptable conversion)

    and the code it is showing as the problem is :

    int DrawEngine::createSprite(int index, wxBitmap *sprite)
    {
    if (index >= 0 && index < 16)
    {
    wxImage img = sprite->ConvertToImage();
    img.SetMaskColour(255, 255, 255);

    //////// Says here is the problem////////////////////////////////
    spriteImage[index] = new wxBitmap(img);
    /////////////////////////////////////////////////////////////////////

    return index;
    }

    return -1;
    }

    Thanks for any help you can give.

  2. #2
    Join Date
    Jan 2010
    Posts
    6
    I could be wrong, because I'm not really a programmer, but it looks as though this thread is talking about the same issue:

    http://www.3dbuzz.com/vbforum/showthread.php?t=153993

    Hope that helps...

  3. #3
    Join Date
    Dec 2004
    Posts
    9
    Yeah thanks. I saw that one, it did help me fix my second problem with the line :

    dc.DrawBitmap(*spriteImage[index], wxPoint(posx * GRID_SIZE, posy * GRID_SIZE), true);

    But I did not see an answer for solving the other line. That is the one still giving me problems. If any needs to see all my code just let me know.

    Thanks for the help.

  4. #4
    Join Date
    Mar 2005
    Posts
    934
    Is that copy-pasted code, or did you retype it? You may have misspelled something. If not, you may have failed to include the header file where the type or class definition was defined.

    Here's a link to an explanation of that error message:
    http://msdn.microsoft.com/en-us/libr...8VS.71%29.aspx
    "I don't WANT to pet the chicken."

  5. #5
    Join Date
    Dec 2004
    Posts
    9
    Pellea, I just copyed and pasted it in. So thanks for the help I will take a look at your link

  6. #6
    Join Date
    Mar 2005
    Posts
    934
    I would find out what index value is being used to access the spriteImage array and make sure there is actually a sprite at that position in the array (remembering zero-based counting: 0, 1, 2, 3, etc.).

    Something like:
    Code:
    int DrawEngine::createSprite(int index, wxBitmap *sprite)
    {
      if (index >= 0 && index < 16)
      {
        wxImage img = sprite->ConvertToImage();
        img.SetMaskColour(255, 255, 255);
    
        // Debugging:
        std::cout << "CreateSprite(): index = " << index << std::endl;
    
        //////// Says here is the problem////////////////////////////////
        spriteImage[index] = new wxBitmap(img);
        /////////////////////////////////////////////////////////////////////
    
        return index;
        }
    
      return -1;
    }
    You'd have to check the console, or wherever standard output writes to on your system.

    Edit: Also, are you sure spriteImage is visible from within this function. I don't use wxWidgets.
    Last edited by pellea72; 01-31-2010 at 01:15 AM.
    "I don't WANT to pet the chicken."

  7. #7
    Join Date
    Jun 2003
    Location
    Trier, Germany
    Posts
    1,350
    Quote Originally Posted by pellea72 View Post
    I would find out what index value is being used to access the spriteImage array and make sure there is actually a sprite at that position in the array (remembering zero-based counting: 0, 1, 2, 3, etc.).
    while this is always a good thing to do, it won't help here. indexing out of bounds is a run-time error, while we're dealing with a compile time error here.

    check the declaration of spriteImage, the error is most probably there.

  8. #8
    Join Date
    Mar 2005
    Posts
    934
    Quote Originally Posted by ComicSansMS View Post
    while this is always a good thing to do, it won't help here. indexing out of bounds is a run-time error, while we're dealing with a compile time error here.

    check the declaration of spriteImage, the error is most probably there.
    In the original post he said he got the error when he "tried to run my code," so I assumed he meant it was a runtime error.

    Edit: Although, I completely ignored the big "Compiler Error" text at the top of the link I posted.
    Last edited by pellea72; 01-31-2010 at 11:49 AM.
    "I don't WANT to pet the chicken."

  9. #9
    Join Date
    Dec 2004
    Posts
    9
    Thanks guys for the help. I was able to solve the problem, ComicSansMS was right. I was missing some " * " in the declaration. So thanks for pointing me in the right direction.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •