Implementing Drawable draw() method?


Last Updated:

  1. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    I'm trying to create an object that will extend the class Drawable. However, I have no clue how to implement the draw() method, but if I don't implement it, nothing gets drawn. What code should I put within the draw() method so that my Drawable is drawn?
     

    Advertisement
  2. couch

    couch Member

    Joined:
    Jul 13, 2010
    Messages:
    6
    Likes Received:
    0
    An obvious suggestion but
    ...
    super.draw();

    might work.
     
  3. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    lol, thanks, but I already tried that.
    Drawable is an abstract class, and Drawable.draw() is an abstract method, so I have to write the code for it explicitly. :p
     
  4. cp1

    cp1 Well-Known Member

    Joined:
    Apr 30, 2010
    Messages:
    375
    Likes Received:
    35
    Are you drawing using canvas?
     
  5. cmh0114

    cmh0114 Well-Known Member This Topic's Starter

    Joined:
    Jan 10, 2010
    Messages:
    116
    Likes Received:
    7
    I think so - a Canvas object is automatically passed in as a parameter to the draw() method.
     
  6. cp1

    cp1 Well-Known Member

    Joined:
    Apr 30, 2010
    Messages:
    375
    Likes Received:
    35
    What are you trying to draw? A picture from a file, or a few lines?
     
  7. jonbonazza

    jonbonazza Well-Known Member

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
    Can you post your code so we can see what we are working with?
     

Share This Page

Loading...