jameswillis
Member
Im new to game maker studio, and im trying to create a sliding menu for a project. I followed a tutorial on youtube to a T, and for some reason the slide bar doesnt work the way its supposed to. I did everything the guy in the video did, but for me, the slider goes only halfway down, and goes up beyond the slider bar. Can anyone tell me what im doing wrong?
Heres a link to the tutorial:
For obj_bar i used the following code:
LEFT PRESSED:
if (mouse_y < bottomLimit) && (mouse_y > topLimit)
{
a.y = mouse_y;
}
CREATE:
topLimit = y - (sprite_height/2) + (image_xscale*75);
bottomLimit = y + (sprite_height/2) - (image_xscale*75);
a = instance_create_layer(x, y, "Instances",obj_slider);
a.image_xscale = image_xscale;
a.image_yscale = image_yscale;
a.barLength = sprite_height;
a.topLimit = topLimit;
a.bottomLimit = bottomLimit;
a.y = topLimit;
a.depth = depth - 1;
For obj_slider i used the following code:
CREATE:
yy = 0;
grab = false;
percentage = 100;
LEFT PRESSED:
grab = true;
yy = y - mouse_y;
left released:
grab = false;
STEP:
if (!mouse_check_button(mb_left))
{
grab = false;
}
if (!grab)
{
exit;
}
else
{
if ((mouse_y + yy < bottomLimit) && (mouse_y + yy > topLimit))
{
y = mouse_y + yy;
}
else if (mouse_y + yy > bottomLimit)
{
y = bottomLimit;
}
else if (mouse_y + yy < topLimit)
{
y = topLimit;
}
}
percentage = round(((y-bottomLimit)/(topLimit-bottomLimit))*100);
Heres a link to the tutorial:
For obj_bar i used the following code:
LEFT PRESSED:
if (mouse_y < bottomLimit) && (mouse_y > topLimit)
{
a.y = mouse_y;
}
CREATE:
topLimit = y - (sprite_height/2) + (image_xscale*75);
bottomLimit = y + (sprite_height/2) - (image_xscale*75);
a = instance_create_layer(x, y, "Instances",obj_slider);
a.image_xscale = image_xscale;
a.image_yscale = image_yscale;
a.barLength = sprite_height;
a.topLimit = topLimit;
a.bottomLimit = bottomLimit;
a.y = topLimit;
a.depth = depth - 1;
For obj_slider i used the following code:
CREATE:
yy = 0;
grab = false;
percentage = 100;
LEFT PRESSED:
grab = true;
yy = y - mouse_y;
left released:
grab = false;
STEP:
if (!mouse_check_button(mb_left))
{
grab = false;
}
if (!grab)
{
exit;
}
else
{
if ((mouse_y + yy < bottomLimit) && (mouse_y + yy > topLimit))
{
y = mouse_y + yy;
}
else if (mouse_y + yy > bottomLimit)
{
y = bottomLimit;
}
else if (mouse_y + yy < topLimit)
{
y = topLimit;
}
}
percentage = round(((y-bottomLimit)/(topLimit-bottomLimit))*100);
Last edited: