Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Extending Bitmap class — Gideros Forum

Extending Bitmap class

techdojotechdojo Guru
edited June 2012 in General questions
Sorry if this is a daft question but...
I'm planning on writing a widget ui library and I was wondering would it be better to create a button class by extending a sprite or a bitmap.
If I extend a bitmap, do I have to provide the same parameters to .new (ie the Texture or Texture region) if not how do I call the parent constructor with the appropriate texture?

Lastly - as bitmap is derived from a sprite, I'm assuming it's possible to call addChild on the bitmap, if so is the parent bitmap drawn first and then the children or is the parent bitmap drawn last?
WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill

Comments

  • atilimatilim Maintainer
    edited June 2012
    Hi @techdojo,

    I would extend from Sprite. (and then I would create a Bitmap and add as a child at init)

    > If I extend a bitmap, do I have to provide the same parameters to .new
    yes. and this is the only way. currently we don't provide a method like super.

    For all classes derived from Sprite (Bitmap, TileMap, TextField, Shape, etc) first the graphics item itself is drawn first and then the children are drawn last.
  • I agree with you, I'd all but decided it would be cleaner to use sprite as a container rather than a bitmap and then add everything as child - I was just wondering if the potential efficiency saving was worth it (probably not).

    As for the child draw order, that probably makes more sense to do it that way :)

    Thanks for the help
    WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
    #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Sign In or Register to comment.