Results 1 to 4 of 4

Thread: Problem: Sprite's share angle even when cloned

  1. #1
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Default Problem: Sprite's share angle even when cloned

    I have multiple sprites on screen that are instances of the same sprite resource. I don't want them to share state, they are independent entities that just happen to look the same, however, if I set_angle on one, it affects the others! Even when I use CL_Sprite::clone(), they share rotation data.

    How can I avoid this? Is this a bug?

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Looking at the source code, it should work.

    However, the API documentation does not make it clear how to do it.

    If the original sprite is SpriteA :

    CL_Sprite SpriteB(gc); spriteB.clone(SpriteA); <--- Should work
    CL_Sprite SpriteB = SpriteA; spriteB.clone(SpriteA); <--- Will not work (share same implementation)
    CL_Sprite SpriteB(); spriteB.clone(SpriteA); <--- Crash! SpriteB is null instance

  3. #3
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Default

    What i have is just like your first example that should work. I don't know why it doesn't, but, someone else tried it and confirmed that it works, so it must somehow be my code..

  4. #4
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Default

    Yeah I found my bug. Oops!!!!

    Definitely not a clanlib bug.

Bookmarks

Bookmarks

Posting Permissions

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