sprite covering the whole screen

Started by rulk, May 03, 2016, 03:38 PM

Previous topic - Next topic

rulk

I'm not sure of I've missed it in the docs, but how do I get a sprite to cover the entire screen.

// works but does not cover the entire display
Logo <- GUISprite( "squirrel_logo.jpg", VectorScreen( 100, 100 ) );
We are all god's children.

Drake

Logo <- GUISprite( "squirrel_logo.jpg", VectorScreen( GUI.GetScreenSize().X, GUI.GetScreenSize().Y ) );

rulk

that dosn't work for me, is that how we do it ?
We are all god's children.

DizzasTeR

sX <- GUI.GetScreenSize().X;
sY <- GUI.GetScreenSize().Y; // Add on top.

Logo <- GUISprite( "squirrel_logo.jpg", VectorScreen( 0, 0) );
Logo.Size = VectorScreen( sX, sY );

rulk

We are all god's children.

.

Quote from: rulk on May 03, 2016, 03:59 PMthat dosn't work for me, is that how we do it ?

Because the second parameter is the position. And you set the position as the screen dimension then the sprite will be positioned after the lower right corner of the screen. Therefore, it doesn't appear on screen.

First you create it on position 0,0:

Logo <- GUISprite("squirrel_logo.jpg", VectorScreen(0, 0));
Then you set the total size of the sprite equal to the screen size:
Logo.Size = GUI.GetScreenSize();
If you want to scale the image as well:
Logo.TextureSize = GUI.GetScreenSize();


EDIT: Sorry, it seems a similar post was made while I was posting this.
.

rulk

I preffer S.L.C's version but dooms works perfect.

Anyhow, I am having trouble removing the GUISprite now. I'm getting
AN ERROR HAS OCCURED [trying to set 'class']

what am I doing wrong ?

http://pastebin.com/raw/rhFqTCuG
We are all god's children.

.

You'll find some decent insight in this discussion. Basically, you have to prefix your global variables/functions with :: all the time.

When you create it:
::Logo <- GUISprite("squirrel_logo.jpg", VectorScreen(0, 0));
And when you use it:
::Logo = null;
Otherwise it's created as a member of the class in which it was executed. Take the following example:

function Script::ScriptLoad()
{
    Logo <- GUISprite("squirrel_logo.jpg", VectorScreen(0, 0));
}

Do you think that's created in the root table? Think again:

function Script::ScriptLoad()
{
    Logo <- GUISprite("squirrel_logo.jpg", VectorScreen(0, 0));
    print(getroottable().rawin("Logo")); // false
}

It's actually created as a member of the Script class.
function Script::ScriptLoad()
{
    Logo <- GUISprite("squirrel_logo.jpg", VectorScreen(0, 0));
    print(Script.rawin("Logo")); // true
}

Therefore you have to use:
Script.Logo = null
Whenever you wish to access that variable. Unless, you prefixed it with :: when you created it and every time you used it after that.



Ask @maxorator , he knows more about this. :P
.

Stormeus

#8
I'd consider it poor convention to declare a global variable from inside a function anyway. You should be declaring your global variables at the top of the script and then referencing them.

Logo <- null;
function Script::ScriptLoad()
{
    Logo = GUISprite("squirrel_logo.jpg", VectorScreen(0, 0));
}

This works as expected and is unambiguous.

MEGAMIND


KAKAN

oh no

MEGAMIND

sry sir but i cant still .....can u plzz just give me the exact code if possible?

DizzasTeR



Spreading hands, calling members 'Sir' and saying 'plzz' won't give you anything.

KAKAN

I no longer script in VCMP :p
but, you can give a try to GUIMemobox
GUIMemobox

Constructor GUIMemobox()

Constructor GUIMemobox(position, size, colour)
Parameter types: VectorScreen, VectorScreen, Colour

Constructor GUIMemobox(position, size, colour, flags)
Parameter types: VectorScreen, VectorScreen, Colour, int

Function AddLine(line)
Parameter types: string. Return type: void.

Function AddLine(line, colour)
Parameter types: string, Colour. Return type: void.

Function Clear()
Return type: void.

Property DisplayPos
Type: float

Property LineHeight
Type: int

Property LineCount (read-only)
Type: int

Property HistorySize
Type: int
oh no

MEGAMIND

Quote from: Doom_Kill3R on Jul 20, 2016, 05:54 PM

Spreading hands, calling members 'Sir' and saying 'plzz' won't give you anything.
im not spreaddiing hands im just giving him respect