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
#6705

s4ge

Hi Alex,

yes I followed the TexturePacker tutorial.

Your example is working just fine, the difference is that your entity isn’t created “at runtime”. I figured out that the scene scale seems to play a big role. For example, when i launch die application, the x scale of the scene is 2, since im using the default window size of 960×640 and the default scene size of 480×320.

Using this information, i tried something on my javascript loop which generates my grid of entities:

 

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

        xSize = 44 / levelScene.xScaleForScene
        ySize = 44 / levelScene.yScaleForScene


        entityManager.removeEntitiesByFilter("brick")

        brickContainer.width = levelData.data.length * xSize
        brickContainer.height = levelData.data.length * ySize
        brickContainer.x = (levelScene.width - brickContainer.width) / 2
        brickContainer.y = (levelScene.height - brickContainer.height) / 2

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

        initialized();
    }

 

As you can see, i now take the current scene scale into account when i set the position of each brick entity and it works just perfect, even if i change the resolution at runtime. However, i wouldn’t expect that, since an object inside of an scaled object should transform it’s child positions automatically, shouldn’t they?

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