Jump to content


Photo

Menu Trouble


  • Please log in to reply
28 replies to this topic

#21 Zealot644

Zealot644

    GMC Member

  • New Member
  • 266 posts
  • Version:GM8

Posted 06 February 2012 - 08:00 PM

I realized I forgot to mention the problem and it has been added to the block of text at the center of my post. Basically spr_select2 wont draw over the buttons in the right click menu like they otherwise would in the original menu at the top left of the screen.

The code others posted could very well work, but I asked for explanations and nobody came back :(

Anyways, if you havent already, please have a look at the GMK file I posted a link to. It can help make more sense of the problem which seems relatively minor =\ but please dont hesitate to ask me questions related to my post, I am more than happy to try and explain the best I can.

Edited by Zealot644, 06 February 2012 - 08:03 PM.

  • 0

#22 Zealot644

Zealot644

    GMC Member

  • New Member
  • 266 posts
  • Version:GM8

Posted 08 February 2012 - 03:35 AM

:sad:
  • 0

#23 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2295 posts
  • Version:GM7

Posted 08 February 2012 - 03:53 AM

Wait, so the problem is the select sprite doesn't appear on the correct one? Change

if mouse_x>0 && mouse_x<928&& mouse_y>0 && mouse_y<672
select = mouse_x && mouse_y;

to (assuming the menu object x,y is in the upperleft corner)

if mouse_x > x && mouse_x< x + (width of the menu) && mouse_y > y && mouse_ y < y + (height of the menu)
{
select = ((mouse_y - y) div (height of each button))
}

Edit: Although this is probably easiest done in the button's event. In which case you should just change the select sprite to the button if mouse_x,mouse_y is in it's bound box.

EditEdit: Shoot that is exactly what torigora suggested. Okay so... what EXACTLY happens when that code is done?

Edited by greep, 08 February 2012 - 04:06 AM.

  • 0

#24 Zealot644

Zealot644

    GMC Member

  • New Member
  • 266 posts
  • Version:GM8

Posted 08 February 2012 - 04:19 AM

The coding you just mentioned applies to the menu at the top left.

The menu in question is one made at the mouse location when you right click, it creates a new menu on that location that expands until you release the RMB. It is on THAT menu in which spr_select2 will not draw over buttons when I scroll over them.

Please, I beg you, download the GMK at the top of my OP and take a look at what I am talking about. I've supplied the necessary explanations the best I can, and have even included the GMK to serve as an additional 'explanation' of sorts.
  • 0

#25 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2295 posts
  • Version:GM7

Posted 08 February 2012 - 04:49 AM

Yeah, I don't have GM 8, so I can't :/. However, no the code I and torigora gave applies to the second menu, not the first. Did you try that code and does it even marginally work?

Edit: By upper left corner, I don't mean in menu 1s place, I mean the mouse_x,y makes the upperleft corner of the menu. If it does not, this code does not work. If it is the upperright, you will have to change some things. Additionally, to double check that this is even marginally working, if the code we gave doesn't work, try taking out the two mouse_x conditions. This will make it so the spr_select will select even if outside the menu, but it should select the right one based on your mouse position.

Edited by greep, 08 February 2012 - 04:51 AM.

  • 0

#26 Zealot644

Zealot644

    GMC Member

  • New Member
  • 266 posts
  • Version:GM8

Posted 08 February 2012 - 10:41 PM

I dont get why you dont have GM 8 ... It's a free upgrade after you bought the program.

I could do the menu in the styling that spr_select2 can draw wherever, but I dont want that as it would end up feeling like lazy and bad design.
  • 0

#27 greep

greep

    Menaces with Spikes

  • GMC Member
  • 2295 posts
  • Version:GM7

Posted 08 February 2012 - 10:45 PM

Right, I never said you should keep that, it was testing. As for why I haven't upgraded, it's because I'm in the tail end of a large project, and I do not wish to convert just in case something gets massively screwed up.

Here's the problem. We're basically giving you a code like direction = 180, and you're saying your object goes right instead of left. Try some stuff, give screenshots of the game, SOMETHING, to tell us what's going wrong. When several experienced novice helpers, particularly torigora, give code that's exactly the same and it's not working, something is not getting across to us.
  • 0

#28 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5379 posts
  • Version:GM:Studio

Posted 09 February 2012 - 02:56 AM

it's this piece of code.. take the position away from mouse position, then the top left corner should be 0 again from any starting position ..
xx=mouse_x-x;
yy=mouse_y-y;

if xx>0 && xx<32*2
&& yy>0 && yy<32
  select = xx div 32;

anyway.. I did a rewrite so everything should work fine ..

create
//Same stuff, different location
show=true;
alpha=0;
select=0;
time=20; // time the menu should use to move into place

x-=16; // move the menu position by 16x16
y-=16;
// one could have changed the sprite origins aswell .. but then you would need to fiddle with some more

for(i=1;i<3;i+=1)instance_create(x,y,obj_right_menu_button) // create the buttons right as instance is created. using mouse enter didnt work when the mouse was already inside
step
// this controls image_alpha - max and min is to keep it between 0 and 1
alpha = min(1,max(0,alpha + (show-!show)*1/time))
//image_alpha = 1-alpha; //alpha for menu - when it is gone then this should be clear
with(obj_right_menu_button)image_alpha = other.alpha*1; // give menu buttons the half the alpha. Old Value was 0.5 

if show=true{
// get the button number you are over if within menu area
xx=mouse_x-x;
yy=mouse_y-y;

if xx>0 && xx<32*2 // it is 2 in width, however, there is another way to check if on the buttons (see draw event)
&& yy>0 && yy<32
  select = xx div 32;

}
global right release
if show=true{
  show=false; // start hiding buttons
  with(obj_right_menu_button){
    alarm[1]=other.time; // tell all menu buttons to start alarm 1 which gets rid of them
    hspeed=-((image_index*32)/other.time); // and move back up
    }
  instance_destroy(); //Destroys the menu after being done to allow the instance_number check on obj_create's right click event to reset to 0.
}
draw
draw_set_alpha(1)

draw_sprite(spr_select2,0,x + 32*select,y) // draw the selection over the right one

if place_meeting(mouse_x,mouse_y,obj_right_menu_button) // if over tower button
  draw_text(x+select*32,y+32,tower_text[select+1]) // then draw tower data

buttons:
create
image_index = instance_number(object_index)-1; //There can clearly only be one of these at a time. Releasing right mouse button, causes this to destroy itself.
image_speed=0;

if image_index < 0 { instance_destroy(); exit; }

alarm[0]=obj_rightclick_button.time; //Changed to new instance. That is all. No further code touched on buttons.
hspeed = (image_index*32)/alarm[0];
alarm event 0 can be changed to:
x=xstart+image_index*32
speed=0;

  • 1

#29 Zealot644

Zealot644

    GMC Member

  • New Member
  • 266 posts
  • Version:GM8

Posted 11 February 2012 - 06:04 PM

Well damn...

Fox saves the day again! +1'd.

Thank you very much. I knew the issue was mostly related to the retrieval of the mouse x and y... I couldnt figure out how to get it to be set in places other than the top left corner with the other menu. Looks like I can finally start working on this some more... I just need to figure out my next steps ^^
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users