Forums

OverviewV-Play 1 SupportSingleSpriteFromFile gets scaled to 0.5 › Reply To: SingleSpriteFromFile gets scaled to 0.5

OverviewV-Play 1 SupportSingleSpriteFromFile gets scaled to 0.5 › Reply To: SingleSpriteFromFile gets scaled to 0.5
#6696

s4ge

I noticed that the sprites actually in correct size, but they draw with a gap. Heres is my code which i use to draw a grid of bricks:

 

<code class="language-qml">    function initialize(levelData){
        var x, y

        entityManager.removeEntitiesByFilter("brick")

        brickContainer.width = levelData.data.length * 22
        brickContainer.height = levelData.data[0].length * 22
        brickContainer.x = (levelScene.width - brickContainer.width) / 2
        brickContainer.y = (levelScene.heigth - brickContainer.heigth) / 2

        for(x = 0; x < levelData.data.length; x++){
            for(y = 0; y < levelData.data.length; y++){
                entityManager.createEntityFromUrlWithProperties(
                    Qt.resolvedUrl("../entities/Brick.qml"),
                    {
                        x: (levelData.data.length - x - 1) * 22,
                        y: (levelData.data[x].length - y - 1) * 22,
                        isEmpty: levelData.data[x][y] === 0,
                        levelScene: levelScene
                    }
                )
            }
        }

        initialized();
    }

 

Prevoiusly, i drawed them by * 44, but that made a gap of 22 which i could not really understand, since the sprite are 44×44 pixel in size. If i draw rectangles using * 44, everythings works like i expect. Do i miss something?

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