Changing the Background Image and font color in-game

Hi!
I'm here with another problem to solve -
In my game, there is an event where the player transfers from one area to another (That's the most vague I can be to prevent spoilers) When that happens, I'd like the text color and the background image to change. Inserting an image just inserts an image on the actual game area with the text and not the background margins. Is there a way to change it so that the background image on the sides of the screen can be altered?
Thanks for helping!


// Changing foreground / background color. (Hex works too)
SetForegroundColour ("Black") // (if you want to change your font color in general, use this.)
SetBackgroundColour ("Red")

// Changing FONT (and size) in game.
SetFontName ("'Courier New', Courier, monospace")
SetWebFontName ("Special Elite")
SetFontSize (12)




// Background image
There's more ways than one but the one I have found most reliable is using CSS.


Edit: Using CSS I've remodelled the entire interface (the location of panes and the graphical structure of the 'page' etc) so I'm not 100% the below code works in a 'template game'. Do try. =)
div#gameBorder {
    background-attachment: fixed !important;
    background-image: url("http://url/pic.png") !important;
    width: auto !important;
} 

(I have lots of stuff in the #gameBorder div but I removed the stuff that doesn't have anything to do with the background image for easier reading.)

Hope this helps.


Thanks so much!
Is there a way to change the font color in-game instead of just in general? (I'm utterly hopeless at coding)
Also, where should I put the div#gameBorder code? I don't know CSS. ;w;


Also, I'm pretty sure my game is written in HTML, not CSS, so is there any way I can incorporate that into the HTML code?


Font (HTML)

If you only want to change a letter/word/sentance/paragraph you can use the font tag.

This:

<font color=blue>This text will be blue</font>
<font color="#0000FF">This text will also be blue (but using the hexadecimal value)</font>

... will look like this:

This text will be blue
This text will also be blue (but using the hexadecimal value)



CSS

There's more than one way to implement your own CSS into the game. If you're not familiar with CSS I'd recommend using SoonGames StyleSheet library. Install it, read the instructions and it should be pretty self explanatory how to change stuff. If you just want to paste the CSS code from the post above you do it under the Stylesheet tab in game (the tab will appear after installing the library).

Good luck =)


Oh. And to reply to this:

Is there a way to change the font color in-game instead of just in general?

This SetForegroundColour ("red") will change the color on all text. You can use it whenever in the game and all text will change (even text that already was printed to the screen)

Use the font-tag (shown in previous post) if you want to change less than all text.


Got it! Thank you so much! :D


To change colour within a block of text, best way is with the text processor.

{color:blue:This text will be blue}
{colour:#0000FF:This text will also be blue (but using the hexadecimal value)}

Also, I'm pretty sure my game is written in HTML, not CSS, so is there any way I can incorporate that into the HTML code?

CSS is the preferred/modern way to tell a browser how the HTML should be displayed, so while your game outputs HTML, in the background the styling is in CSS.


Log in to post a reply.

Support

Forums