Position on Screen

Status
Not open for further replies.

Arch

Legions Developer
Any way to changing the position on screen within scripts? What I mean is send an image to the background when it is the at the bottom of the script. And yes, it does need to be at the bottom of the script or else it will not work correctly.
 

Arch

Legions Developer
Change the position of... The Screen itself? As in.. the game window?
No no no. I have an image that I placed into the HUD through the script. The issue is that it shows over things that it shouldn't. I am wondering if there was a way to force the image to the background without moving the chunk of code to the top of the whole script.
Code:
function HudOverlay::AddHudElements(%this)
    {
        parent::AddHudElements(%this);
 
// Line 1 message text
%index = %this.addHudElement();
%this.setHudElementPosition(%index, 490, 125);
%this.setHudElementPositionAnchor(%index, "VCenter", "HCenter");
%this.setHudElementScreenAnchor(%index, "Top", "HCenter");
%this.setHudElementBaseTextureSize(%index, 820, 116);
%this.setHudElementColor(%index, 255, 255, 255, 0);
%this.setHudElementParent(%index, $HudElement::BaseContainer);
%this.setHudElementRenderWhenDead(%index, true);
$HudElement::KP1MessageText = %index;
 
// BG1
%index = %this.AddHudElement();
%this.setHudElementPosition(%index, 490, 125);
%this.setHudElementTexture($HudElement::KP1MessageText, "mods/autoexec/Koncept/BG");
%this.setHudElementParent(%index, $HudElement::BaseContainer);
%this.setHudElementPositionAnchor(%index, "HCenter", "VCenter");
%this.setHudElementRenderWhenDead(%index, true);
//%this.setHudElementDrawRect(%index, true);
$HudOverlay::BackgroundOne = %index;
I want the second chunk of code, which is an image, to lay under the other, which is text, when they are displayed on the HUD without moving the chunk of code up in the script due to it causing some issues with this...
Code:
%this.setHudElementTexture($HudElement::KP1MessageText, "mods/autoexec/Koncept/BG");
 

Arch

Legions Developer
Uh... You could call it higher up in the script?

What is this for?
Exactly what I can't do. I'm adding a BG to the KillPop script. The second chunk responds to the first chunk so it has to be after it or else it causes some major issues in showing the HUD elements.
Code:
%this.setHudElementTexture($HudElement::KP1MessageText, "mods/autoexec/Koncept/BG");
This makes it respond to the element above it in the script. Named KP1MessageText.
 

Volt Cruelerz

Legions Developer
Could you redraw the original image after the second image? You'd define the first earlier on, but you'd redraw it at the end. If not, so far as I know, it sounds like you may have to restructure your code :/
 

RockeyRex

Legions Developer
Code:
function HudOverlay::AddHudElements(%this)
{
   parent::AddHudElements(%this);
   // BG1
   %index = %this.AddHudElement();
   %this.setHudElementPosition(%index, 490, 125);
   %this.setHudElementParent(%index, $HudElement::BaseContainer);
   %this.setHudElementPositionAnchor(%index, "HCenter", "VCenter");
   %this.setHudElementRenderWhenDead(%index, true);
   //%this.setHudElementDrawRect(%index, true);
   %this.setHudElementTexture(%index, "mods/autoexec/Koncept/BG");
   $HudOverlay::BackgroundOne = %index;
 
   // Line 1 message text
   %index = %this.addHudElement();
   %this.setHudElementPosition(%index, 490, 125);
   %this.setHudElementPositionAnchor(%index, "VCenter", "HCenter");
   %this.setHudElementScreenAnchor(%index, "Top", "HCenter");
   %this.setHudElementBaseTextureSize(%index, 820, 116);
   %this.setHudElementColor(%index, 255, 255, 255, 0);
   %this.setHudElementParent(%index, $HudElement::BaseContainer);
   %this.setHudElementRenderWhenDead(%index, true);
   $HudElement::KP1MessageText = %index;
}
 

Arch

Legions Developer
Code:
function HudOverlay::AddHudElements(%this)
{
  parent::AddHudElements(%this);
  // BG1
  %index = %this.AddHudElement();
  %this.setHudElementPosition(%index, 490, 125);
  %this.setHudElementParent(%index, $HudElement::BaseContainer);
  %this.setHudElementPositionAnchor(%index, "HCenter", "VCenter");
  %this.setHudElementRenderWhenDead(%index, true);
  //%this.setHudElementDrawRect(%index, true);
  %this.setHudElementTexture(%index, "mods/autoexec/Koncept/BG");
  $HudOverlay::BackgroundOne = %index;
 
  // Line 1 message text
  %index = %this.addHudElement();
  %this.setHudElementPosition(%index, 490, 125);
  %this.setHudElementPositionAnchor(%index, "VCenter", "HCenter");
  %this.setHudElementScreenAnchor(%index, "Top", "HCenter");
  %this.setHudElementBaseTextureSize(%index, 820, 116);
  %this.setHudElementColor(%index, 255, 255, 255, 0);
  %this.setHudElementParent(%index, $HudElement::BaseContainer);
  %this.setHudElementRenderWhenDead(%index, true);
  $HudElement::KP1MessageText = %index;
}
That would do it but only one problem. I'm trying to make the background respond to the "Line 1 message text" chunk so when text appears when you kill someone, so does the BG (and disappears when the text goes away). Placing it above that chunk of code causes issues when I want to have it respond to it.

I was messing around with it earlier and found this at the bottom of the script..
Code:
function FadeInKP1()
{
$KP1act=true;
HudOverlay.AnimateHudElementAlpha($HudElement::KP1MessageText, 255, 0.2);
I added in..
Code:
HudOverlay.AnimateHudElementAlpha($HudElement::BackgroundOne, 255, 0.2);
And moved that "BG1" chunk above the other. Seemed to animate together but still drew the BG over the text- the same thing as parenting the bg texture to the "K1MessageText".
 
Status
Not open for further replies.
Top