Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Image Positioning on the z-axis

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6025

    Pi

    Hi,

    I am trying to position two items (an image and a spritesequence) on the z axis.

    When I use SpriteSequence the sprite appears above the image even though the z value is less than that of the image

        EntityBase{
            id: menubg
            z: 1
            Image {
                //id: sprite
                width:480
                height:320
                z: 1
    
                source: "img/menubg.png"
            }
        }
        EntityBase{
            id:headbob
            z:0
            x: 10
            y: 40
            SpriteSequence{
                spriteSheetSource:"img/headbob.png"
               Sprite {
                   
                   scale: .3
                   id: sprite
                   frameWidth: 383
                   frameHeight: 310
                   frameCount: 12
                   startFrameColumn: 1
                   frameRate: 10
    
                 }
            }
    
        }
    

     

    But if I use an image or just sprite the positioning comes as expected. Is this a bug?

        EntityBase{
            id: menubg
            z: 1
            Image {
                //id: sprite
                width:480
                height:320
                z: 1
    
                source: "img/menubg.png"
            }
        }
        EntityBase{
            id:headbob
            z:0
            x: 10
            y: 40
               Sprite {
                   source: "img/headbob.png"
                   scale: .3
                   id: sprite
                   frameWidth: 383
                   frameHeight: 310
                   frameCount: 12
                   startFrameColumn: 1
                   frameRate: 10
    
                 }
        }

     

     

    #6028

    Alex
    Felgo Team

    Hi,

    the advantage of using spritesheets is that all sprites are drawn in one draw call. This also means they are all drawn in one logical layer. You can define the position of that layer using the SpriteBatchContainer. If you don’t make use of the Container, the sprites will be drawn last, on top of all other items (that’s what you are experiencing in your first example).

    So you can either find a good place for the SpriteBatchContainer, or put everything that should be on top of the sprites into a spritesheet too, and also use it with the SingleSprite… and SpriteSequence… components.

     

    By the way, why are you using an EntityBase for your menubg? This component is normally meant to be used for game entities.

    Best Regards,
    Alex

    #6029

    Pi

    Hi Alex,

    Thanks for the clarification.

    You’re right, the menubg does not belong in an EntityBase. I just put it there as a last ditched effort to correct the z-positioning 🙂

     

    Oh and I think there is a typo in the last line of this page

    http://felgo.com/doc/vplay1-spritebatchcontainer.html

    “By now, define the …” should be “For now,…”

     

    Regards,

    Piyush

    #6030

    Alex
    Felgo Team

    Yeah you are right, “For now” is correct in that context, we will change that, thank you 🙂

    Best Regards,
    Alex

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded