Timofii Posted June 10, 2021 Share Posted June 10, 2021 Hi! When i increment sprite.y coordinate inside the game loop, the sprite moves to bottom, like y increment is below zero. Console values of increment and sprite.y is above zero. Attaching my code: let renderer, stage, character, sprite; const alpha = 45, tanAlpha = Math.tan(alpha / 180*Math.PI); function setup () { renderer = PIXI.autoDetectRenderer( {backgroundAlpha: 0}); character = PIXI.Texture.from('Content\\images\\slogosb.png'); stage = new PIXI.Container(); sprite = new PIXI.Sprite(character); stage.addChild(sprite); document.getElementById('view').appendChild(renderer.view); animate(); } function animate () { //Loop this function 60 times per second requestAnimationFrame(animate); //Move the sprite 1 pixel per frame sprite.x += 0.5; sprite.y = sprite.x * tanAlpha; //Render the stage renderer.render(stage); } setup(); Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 10, 2021 Share Posted June 10, 2021 > i increment sprite.y coordinate > the sprite moves to bottom, in which environment/framework/whatever you coded graphics applications before? I have a surprise for you: in most of 2d apps, Y is going doooooown. b10b, a-c-sreedhar-reddy and Timofii 1 2 Quote Link to comment Share on other sites More sharing options...
b10b Posted June 11, 2021 Share Posted June 11, 2021 Yep ... think of it as "reading a page" rather than "flying a plane" then it'll make a bit more sense until it becomes automatic. Why is Y down? iirc it's to do with gravity, and how on early raster displays there are no lines, just a gradual droop of the ray with a period return of the X, and a period return of the Y as a multiple of the X period. Timofii 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.