A simple question

Posted By: Skeksis

A simple question - 07/04/08 17:40

I'm currently working on a simple inventory, when viewing the inventory I want to be able to cycle through the items by pressing a or d. I can scroll the items by doing something like if (key_d == 1) { weapon1_ent.y += 5* time_step; }
the above code just scrolls it along the y axis for as long as I hold d, I only want it to scroll a certain distance though instead of scrolling infinitely. I hope that made sense, and I hope someone can help.
Posted By: DJBMASTER

Re: A simple question - 07/04/08 18:42

hi you can achieve this using a loop.
Code:
 
function move_me()
{
var current_pos=0;
while(current_pos<=30){mypanel.pos_y+=1; current_pos+=1; wait(1);}
current_pos=0;
}


current_pos<=30 > 30 is the amount you want to move it.
mypanel.pos_y+=1 > 1 is the speed you want to move it.
mypanel.pos_y+=1 will change the panel's y direction. Use pos_x instead for the other direction.

You can then attach this to something like on_d=move_me; in main() or another function.
Posted By: Skeksis

Re: A simple question - 07/04/08 20:58

Thank you for the help, it works perfectly.
© 2024 lite-C Forums