Post: Easy way to position Shaders/Text
12-31-2011, 06:39 PM #1
d7w7z
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); I was making a menu and got annoyed by the fact I had to keep making the patch over and over trying to guess good X and Y values, So I made this function to move elements around the screen.

    
PosTest(D) {
switch(D) {
case "U":
self moveOverTime( .1 );
self.Moving[self.TestNum].y -= 5;
break;
case "D":
self moveOverTime( .1 );
self.Moving[self.TestNum].y += 5;
break;
case "L":
self moveOverTime( .1 );
self.Moving[self.TestNum].x -= 5;
break;
case "R":
self moveOverTime( .1 );
self.Moving[self.TestNum].x += 5;
break;
case "Re":
self iPrintln("x: " + self.Moving[self.TestNum].x);
self iPrintln("y: " + self.Moving[self.TestNum].y);
break;
case "Sw":
self.TestNum++; if(self.TestNum > self.Moving.size) { self.TestNum =0; }
self iPrintln("Editing " + self.TestNum);
break;
} }

LoopRun( function, event, input) {
for(;Winky Winky {
self waittill( event );
self thread [[function]]( input );
} }



Make a function like this and add all the items you want to be able to move(shaders and text both work) to self.Moving. Don't forget to change "dpad_XXXX" to whatever controls your menu uses.
    
MenuDebug() {
self.Moving=[]; self.TestNum=0;
self.Moving[0]=self.scrollbar1;
self.Moving[1]=self.BackGroundHud;

self thread LoopRun( ::PosTest, "dpad_right", "R"); //Move Right
self thread LoopRun( ::PosTest, "dpad_left", "L"); //Move left
self thread LoopRun( ::PosTest, "dpad_up", "U" ); //Move Up
self thread LoopRun( ::PosTest, "dpad_down", "D"); //Move Down
self thread LoopRun( ::PosTest, "button_cross", "Re"); //Print X and Y values of current element
self thread LoopRun( ::PosTest, "button_square", "Sw"); //Switch to next element in self.Moving
}


Once you fine a good spot, print the X and Y then put the values as the X and Y for your element.
I might also add a way to scale the item up/down later...
(adsbygoogle = window.adsbygoogle || []).push({});

The following 2 users say thank you to d7w7z for this useful post:

Cmd-X, x_DaftVader_x
12-31-2011, 09:57 PM #2
Nice work man, if you want to make it even more in depth, make an options menu to go with it so you can do more things like change the relatives and what not.
01-01-2012, 12:59 PM #3
Correy
I'm the Original
do the 'self waittill( "DPAD_UP" );' ect.. work?, and after so long you just know where to posision then :p
01-01-2012, 07:34 PM #4
d7w7z
Bounty hunter
Originally posted by Correy View Post
do the 'self waittill( "DPAD_UP" );' ect.. work?, and after so long you just know where to posision then :p

I meant change them to the notify's that your menu uses. Obviously there is a way to get dpad buttons working, IW uses it for the game menu.
01-01-2012, 08:23 PM #5
Correy
I'm the Original
Originally posted by d7w7z View Post
I meant change them to the notify's that your menu uses. Obviously there is a way to get dpad buttons working, IW uses it for the game menu.


    
Shader( element )
{
p = self createFontString( undefined, 2 );
p setPoint( "TOPRIGHT" );
for(;Winky Winky
{
element.y += attackButtonPressed();
element.x += adsButtonPressed();
p setText( element + " Y: " + element.y + " " + element + " X:" + element.x );
wait .3;
}
}
01-01-2012, 08:58 PM #6
d7w7z
Bounty hunter
Originally posted by Correy View Post
    
Shader( element )
{
p = self createFontString( undefined, 2 );
p setPoint( "TOPRIGHT" );
for(;Winky Winky
{
element.y += attackButtonPressed();
element.x += adsButtonPressed();
p setText( element + " Y: " + element.y, element + " X:" + element.x );
}
}

Serious?

Super lag because no wait in function, probly will crash the game. setText would crash the game before you got anything useful done if the lag didn't.

The following user thanked d7w7z for this useful post:

247Yamato
01-01-2012, 09:32 PM #7
Correy
I'm the Original
Originally posted by d7w7z View Post
Serious?

Super lag because no wait in function, probly will crash the game. setText would crash the game before you got anything useful done if the lag didn't.


it wont lag bad, its only setting a value.. but it does need a wait :p
i had a , in the setText because it was an iPrintln and forgot to change it ha.
01-01-2012, 09:42 PM #8
d7w7z
Bounty hunter
Originally posted by Correy View Post
it wont lag bad, its only setting a value..


It would do the loop a few thousand times per second. Each loop would set 2 variables, check if a 2 buttons are pressed or not and call the setText function. No lag at all. :P
01-01-2012, 09:47 PM #9
Correy
I'm the Original
Originally posted by d7w7z View Post
It would do the loop a few thousand times per second. Each loop would set 2 variables, check if a 2 buttons are pressed or not and call the setText function. No lag at all. :P


but, it still works..
01-01-2012, 09:56 PM #10
d7w7z
Bounty hunter
Originally posted by Correy View Post
but, it still works..

Hitting a door with a sledge hammer also works for getting through it, Doesn't mean you should do it.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo