Coder Social home page Coder Social logo

Comments (8)

elnormous avatar elnormous commented on May 19, 2024

Content position is set so that you know where the content's left bottom position is in the viewport. It is not being used, because scale modes need only scale factor to be calculated and then applied to the scene.

from ouzel.

wenq1 avatar wenq1 commented on May 19, 2024

So it is the viewport that actually gets centered? I don't see that implemented in the code either ... Maybe I missed it somehow?

from ouzel.

elnormous avatar elnormous commented on May 19, 2024

This is the line that creates the scaled orthographic matrix: https://github.com/elnormous/ouzel/blob/master/ouzel/scene/Camera.cpp#L91

from ouzel.

wenq1 avatar wenq1 commented on May 19, 2024

I fully understand this orthographic matrix. However when I use the engine, say with an example device screen size of 1200x1920, and targetContentSize of 600x800, the contentScale is correctly set to 2. But when I try to draw a 600x800 sprite at position (0, 0), it is drawn on the bottom left corner of the device screen. I am expecting it being drawn vertically centered on the screen, WITHOUT manually setting the position, hence the question.

from ouzel.

wenq1 avatar wenq1 commented on May 19, 2024
Device: 1200x1920
+------+
|      |
+------+
+sprite|
|------+
|      |
+------+
     

targetContentSize: 600x800
draw sprite of size (600x800) at (0, 0)

Expected
+------+
|      |
+------+
+sprite|
|------+
|      |
+------+


Actual
+------+
|      |
|      |
|      |
+------+
+sprite|
|------+


from ouzel.

elnormous avatar elnormous commented on May 19, 2024

What scale mode are you using? Can you please post your code somewhere?

from ouzel.

wenq1 avatar wenq1 commented on May 19, 2024

nothing special here. Basically it boils down to



        videoLayer = new Layer ()

        videoCamera        = new Camera ('show-all');
        videoCamera.setTargetContentSize (600, 400);
        videoLayer.addCamera (videoCamera);
        addLayer (videoLayer);

        videoSprite    = new Sprite (600, 400);
        videoNode      = new Node ();
        videoNode.setPosition (0, 0);
        videoNode.addComponent (videoSprite);

        videoLayer.addChild (videoNode);


from ouzel.

wenq1 avatar wenq1 commented on May 19, 2024

Ah.. I see. Ouzel has center of the screen as the origin, whereas I'm assuming the bottom-left corner.. How interesting..

from ouzel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.