Setting a Background for my game

Setting a Background for my game
0

#1

lately I have been following some tutorials and this is how they set the background
backgroundsprite->setPosition(Vec2(visibleSize.width/2 + origin.x , visibleSize.height/2 + origin.y));
but what I noticed was when I remove “+ origin.x” and “+ origin.y” I got the exact same thing and asked the creator of the tutorial and he said it “origin.x ensures maximum compatibility when some devices origin is off” does anyone know what he means by this ? how could a devices origin be off and now im wondering will the origin being off affect other sprites positions in my game and cause things to be not where there supposed to be ?

UPDATE: i think this is only a issue when resolution policy is set to “NO_BORDER”


#2

I’ve never heard of what this developer said to you. I don’t use a lot more than visibleSize.height / 2, etc…width, etc


#3

It was on this tutorial sonary systems I asked on the comments


#4

I appreciate the effort they put in for these tutorials and I’ve talked with them several times. However, I feel they had a different way of coding than I would. I guess that goes without saying thought. We all code differently.


#5

origin is (0,0)
visibleOrigin has a different value which depends on the size of the display
(visibleSize.width/2, visibleSize.height/2) is the exact centre of the screen

MandarX


#6

so it’s not a good idea to just base it on the centre of the tab size (if a tab is 500, 600 then I’d set a background at Point(250, 300)) ? Darn have I been positioning assets wrong this whole time?


#7

No it is not wrong but the “origin.x” is unneccesary.
There might be a case where origin x isnt 0/0 I guess @slackmoehrle. Maybe on long devices (galaxy s9+), nc the display is not filled complerely ?

5+0=5


#8

but if you’re making an android landscape game, do you change the tab size?


#9

You base the tab size on the screen size. You know the screen size from AppDelegate.