Hello Guest

Author Topic: Multiple graphics in one Entity - location question  (Read 944 times)

0 Members and 1 Guest are viewing this topic.

bacek

  • Member
  • Posts: 2
    • View Profile
Multiple graphics in one Entity - location question
« on: February 20, 2017, 07:12:52 AM »
Hello.
At first, thank you for simple and fast library.
I've got a question about multiple graphics. I have a spaceship sprite and a flame animation. They are always together, so I decide to add both graphics into one entity.
How can I change the location of flame? AddGraphics have no x,y arguments. I could use 2 entities, but in that case I'll need to change coordinates of flame manually when ship moves.
Here's constructor of my object
Code: [Select]

public Player() : base(Game.Instance.HalfWidth, Game.Instance.HalfHeight)
        {
            var img = new Image("Resources/player.png");
            img.CenterOrigin();
            AddGraphics(img);

            Spritemap<Animation> spritemap;
            spritemap = new Spritemap<Animation>("Resources/flame.png", 32, 64);
            spritemap.Add(0, "0,1,2,3,4,5,6,7", 10);
            spritemap.CenterOrigin();
            spritemap.Play(Animation.fire, true);
            AddGraphics(spritemap);
        }

What I see and what I need:

Thank you.
« Last Edit: February 20, 2017, 07:18:50 AM by bacek »

badman

  • Member
  • Posts: 3
    • View Profile
Re: Multiple graphics in one Entity - location question
« Reply #1 on: February 21, 2017, 07:58:37 AM »
spritemap.SetPosition(0f, image.Height);

bacek

  • Member
  • Posts: 2
    • View Profile
Re: Multiple graphics in one Entity - location question
« Reply #2 on: February 21, 2017, 09:40:24 AM »
spritemap.SetPosition(0f, image.Height);
Thank you, bro. That's exactly that I need.