How to make moving huds? to they are moving on screen?
Thanks.!
Printable View
How to make moving huds? to they are moving on screen?
Thanks.!
use moveovertime, scaleovertime and fadeovertime
that? its not updating huds..Code:something()
{
self endon("disconnect");
if(isdefined(self.m))
self.m destroy();
self.m = newClientHudElem(self);
self.m.x = 550;
self.m.y = 90;
self.m.alignX = "left";
self.m.alpha = 0;
self.m.sort = 50;
self.m.fontScale = 1;
self.m.archived = true;
for(;;)
{
self.m fadeOverTime(1);
self.m moveOverTime(5);
self.m.alpha = 1;
self.m.label = &"something:";
self.m setValue(self.something);
wait 300;
self.m fadeOverTime(1);
self.m.alpha = 0;
wait 10;
}
}
you set the coordinates of the hud. Then you do moveovertime(time) and then the new coordinates of the hud
Learning by example ftw:
PHP Code:
self.m moveOverTime(1);
self.m.x = 550;
self.m.y = 90;
wait 1;
self.m moveOverTime(1);
self.m.x = 10;
self.m.y = 10;
wait 1;
self.m moveOverTime(1);
self.m.x = 222;
self.m.y = 222;
wait 1;
self.m moveOverTime(1);
self.m.x = 320;
self.m.y = 240;
wait 1;
i think its what i want too but i do not knew how create :)
i would like a text who is from left and who rotate for the right
i have the HTML to create on website:
<marquee direction="left" behavior="scroll" scrollamount="3" scrolldelay="2" style="color:#000000;font-size:32px;font-family:Arial;">my website<br>
<br></marquee>
He is just refering to the html-element marquee as an analogy for a hud moving from right to left.
As base you could use this old ad hud script: http://killtube.org/downloads/cod2/e...ain/std/ad.gsc
You basically just need to edit the for loop in ad::ad() to move it with moveOverTime() like shown in the example.PHP Code:
std\ad::addAd(&"1st marquee", 2, (1,0,0));
std\ad::addAd(&"2nd marquee", 2, (0,1,0));
std\ad::addAd(&"3rd marquee", 2, (0,0,1));
std\ad::precache();
// in startgametype:
thread std\ad::ad();
PHP Code:
while (1)
{
for (i=0; i<level.ad.size; i++)
{
level.hud_ad.fontscale = level.ad[i].scale;
level.hud_ad.color = level.ad[i].color;
level.hud_ad fadeOverTime(1);
level.hud_ad.alpha = 1;
level.hud_ad.label = level.ad[i].ad;
wait 10;
level.hud_ad fadeOverTime(1);
level.hud_ad.alpha = 0;
wait 20;
}
}
Is there any way to do a shader from .alpha 0 to .alpha 1 in 5 secounds? I tried it and there is a problem, it just showed the shader instantly. If you try it on the default shader "black", then you will see, that it works. But not on own shaders. I tried already fadeOverTime(time) too, but it doesn't work, only on text.
Shaders work too with fadeovertime
PHP Code:
{
hud = newClientHudElem(self);
hud.horzAlign = "fullscreen";
hud.vertAlign = "fullscreen";
hud setShader("white", 640, 480);
hud.alpha = 1;
hud.x = 0;
hud.y = 0;
hud fadeovertime(2.5);
hud.alpha = 0;
}
Doesn't work, you tested it with your own texture?
If yes and if it does work, then do a .iwd file and upload here, I want to check it.
Edit: My current HUD script:
notes:PHP Code:
spawnHud()
{
hud = newClientHudElem(self);
hud.horzAlign = "fullscreen";
hud.vertAlign = "fullscreen";
hud setShader("texture_test", 640, 480);
hud.alpha = 1;
hud.x = 0;
hud.y = 0;
hud fadeovertime(10);
hud.alpha = 0;
self thread destroyOnDeath(hud);
}
destroyOnDeath(hud)
{
self waittill("killed_player");
if(isDefined(hud))
hud destroy();
}
- spawnHud() will be called if someone is spawning
- destroyOnDeath() will be called if someone die
- the shader "texture_test" is precached
- the hud spawns instantly (visible) and not from visible to invisible
In game it looks like this (after spawned):
Attachment 676
The thing I posted works. I use it for flashnade. The shader "white" is a default cod2 shader. I didnt test it with own texture. Maybe you need to compile your shader with certain options to make it work
fadeOverTime() works on shaders as well.
Example of a working fading server logo shader:
PHP Code:
if( isdefined( level.svrlogo ) ) level.svrlogo destroy();
if( !isdefined( level.svrlogo ) )
{
level.svrlogo = newHudElem();
level.svrlogo.x = X;
level.svrlogo.y = Y;
level.svrlogo.hidden = false;
level.svrlogo.alignX = "left";
level.svrlogo.alignY = "top";
level.svrlogo.horzAlign = "fullscreen";
level.svrlogo.vertAlign = "fullscreen";
level.svrlogo.archived = false;
level.svrlogo.hideWhenInMenu = true;
level.svrlogo setShader( game[ "demonlogo" ], W, D );
level.svrlogo.alpha = 0;
}
for( ;; )
{
wait looptime;
if( isdefined( level.svrlogo ) ) level.svrlogo fadeOverTime( 2 );
if( isdefined( level.svrlogo) ) level.svrlogo.alpha = .7;
wait screentime;
if( isdefined( level.svrlogo ) ) level.svrlogo fadeOverTime( 2 );
if( isdefined( level.svrlogo ) ) level.svrlogo.alpha = 0;
}
No, now I found the problem, I looked on the material and image from the shader "black" and "white".
The material name is "black" and the image name is "$black" (open the material from main/iw_13.iwd/materials/black to see what image name it has).
You can also read the options what there is used for the material, but I it's just hard to understand, what they set:
Code:V \ e‘( P D P c \ tools black $black colorMap