Forums

OverviewV-Play 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
    V-Play 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://v-play.net/doc/vplay1-spritebatchcontainer.html

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

     

    Regards,

    Piyush

    #6030

    Alex
    V-Play 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support