Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -



Post new topic Reply to topic  [ 4 posts ] 
    gamekill
  Mon Apr 02, 2012 8:35 pm
Member

I am trying to dynamically position a "Score" text element, on my hud (like "Score: 2300 pts"), at the horizontal center of the player's screen, under any resolution the game is played.
So I figured I'd set the Score.X to Screenwidth/2 at the beginning of the Layout.
I guess it is kind of working, but ScreenWidth is being reported wrong or something, because the Textbox (Score) is positioned not on the center of the game window but a bit to the left..

Also, on another case, I set the game character's Sprite to automatically bounce back whenever it hits the left or right borders of the game. But again, for this I am using Screenwidth (for the right border "X" position check). And again, the sprite goes past the right screen border for a bit (but ends up finally bouncing back).

So my guess is, ScreenWidth is reporting the wrong size.

Is this a known bug or something like that?
Or am I doing it wrong??

EDIT: It all works flawlessly when I go Fullscreen (F11) and reload the game (ScreenWidth is reported correctly). Is there a way to make it work in random-sized windowed mode?

:shock: :smile: :o: :?: :?:


Top Top
Profile      
 

    ForeverZer0
  Mon Apr 02, 2012 10:12 pm
ARC Developer
User avatar
Sponsor


Location: United tates
Make sure you are using the CLIENT width, not the width of the window, which will include borders.

_________________
Use DropBox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account. ;)

Looking for a more powerful RMXP? Check out Image

My complete script list on Pastebin


Top Top
Profile      
 

    joannesalfa
  Mon Apr 02, 2012 10:58 pm
User avatar
Member

Alternatively, did you use anchor behavior?

To get it to stay relative to a position on-screen


Top Top
Profile      
 

    valkyriegames
  Tue Apr 03, 2012 6:12 am
User avatar
Awesome Bro


Location: Australia
It's because you're using ScreenWidth instead of WindowWidth. The ScreenWidth is the size of the user's computer screen that's why on full screen it works. Windowwidth gives you the width of the HTML5 Canvas area. Hope that helps!

_________________
Image

Content Hidden


Image
Content Hidden


Top Top
Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Homepage
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group