Jump to content


ProGen

Member Since 03 Oct 2011
Offline Last Active Oct 05 2011 02:49 PM

Topics I've Started

Instance position help

04 October 2011 - 04:48 PM

quite new to GML and need help with my top down game's main menu.

basically what I am trying to accomplish is to make a simple menu with  4 selectable objects and an object that the user moves up and down with the keyboard arrows to select them. My approach :
create the four objects , use the same animated sprite and set image_index to the desired button ( e.g play,exit etc) , create the selector object with its own sprite. LAYOUT :
obj_selector's create event
global.move_up=0
globalvar move_up
global.move_down=0
globalvar move_down

image_speed=1
with (obj_selector)
{
x=obj_play.x // obj_play = the first obj in the menu
y=obj_play.y
}

keyboard up and down
if move_up=1             // if move_down=1 (for the keyboard down)
{
with (obj_selector)
x=obj_selector.x
y=obj_selector.y-63  // +63 in the keyboard down
sound_play(sound_select0);
}
my problem
step event for obj_play
if instance_position(x=obj_play.x,y=obj_play.y,obj_selector) // i think this is where I went wrong

move_up=0
move_down=1

so basically i need to set move up to 0 when obj_selector is over obj_play so that obj_play cannot move y-63
because obj_selector is created on obj_play which is the first option in the menu.any help will be greatly appreciated
:smile: