Author Topic: Move game selection like a menu  (Read 4265 times)

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Move game selection like a menu
« on: January 28, 2017, 06:27:39 PM »
I’m looking to have some objects on screen operate as such in my x’s and o’s. Numbers are list entry. O is a selected game. Any insight?

1 2 3 4
O x x x

->

1 2 3 4
x O x x

->

1 2 3 4
x x O x

->

1 2 3 4
x x x O

->

2 3 4 5
x x x O

<-

2 3 4 5
x x O x

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Move game selection like a menu
« Reply #1 on: January 29, 2017, 07:14:21 PM »
I'm not sure if that fully describes what you want to do... might need a little more detail - but that is similar to using a conveyor?

If your object is say the boxart, you need to show the user which is selected - maybe have a background highlight or have the selected one be larger than the rest..

If conveyor wouldn't work for you, you could create your own "custom object". You can write a GameSelect class, that creates its own surface - adds the game objects (i.e. 4x boxarts) and then using on_transition or on_ticks - adjust your objects to update and show which is selected.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Move game selection like a menu
« Reply #2 on: January 29, 2017, 07:24:20 PM »
I'm not sure if that fully describes what you want to do... might need a little more detail - but that is similar to using a conveyor?

If your object is say the boxart, you need to show the user which is selected - maybe have a background highlight or have the selected one be larger than the rest..

If conveyor wouldn't work for you, you could create your own "custom object". You can write a GameSelect class, that creates its own surface - adds the game objects (i.e. 4x boxarts) and then using on_transition or on_ticks - adjust your objects to update and show which is selected.

I just looked at the conveyor module. Orbit layout seems to function somewhat similar to what I was thinking - just without the vertical navigating. Module is overwhelming. I’ll spend some time with it. Thank you.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Move game selection like a menu
« Reply #3 on: January 30, 2017, 04:20:34 AM »
Yeah, conveyor was a bit confusing even to me - later tonight I'll give you an example and maybe an alternate option...

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Move game selection like a menu
« Reply #4 on: January 30, 2017, 04:41:57 PM »
Alright, so simplistic approach - Conveyor already contains a class called SimpleArtStrip - this does what you want, but the way it is written, it will always keep the selected game in the same slot. Using it is as simple as this:

Code: [Select]
fe.load_module("conveyor")
local strip = SimpleArtStrip("snap", 5, 0, 0, 800, 200, 10)

But breaking down how the conveyor class works - Conveyor is a class which when instantiated, creates multiple objects for you. You pass it some parameters and its code creates the objects based on your parameters. The conveyor class has an array of objects that it will work with - and any class that extends Conveyor will define what that object is. This is done with a separate class called a ConveyorSlot.

The conveyor class has an example extended class called SimpleArtStrip - which makes use of an extended SimpleArtStripSlot class to define and position objects - in this case it just makes a bunch of artwork objects.

Most of conveyor relates to transitioning/animating the objects - positioning each of them when you move through the list.

If you want to make your own custom objects however, you can. You can make a class which contains its own surface, adds multiple objects to that surface, and if you want, could  handle animating and positioning them based on where the user is in the list. That would go something like this:

Code: [Select]
class GameMenu {
    surface = null
    objects = null
    count = 0
    constructor( x, y, w, h, num, parent = ::fe ) {
        surface = parent.add_surface(w,h)
        surface.set_pos(x, y)
        count = num
        objects = []
        local index = -floor( count / 2 )
        local obj_width = surface.width / count
        for( local i = 0; i < count; i++) {
            local obj = surface.add_artwork("snap", -1, -1, 1, 1)
            obj.set_pos( obj_width * i, 0, obj_width, h )
            obj.preserve_aspect_ratio = true
            obj.index_offset = index
            objects.push( obj )
            index++
        }
        ::fe.add_transition_callback(this, "on_transition")
    }
   
    function set_pos( x, y, w, h ) {
        surface.set_pos( x, y, w, h )
    }
   
    function on_transition(ttype, var, ttime) {
        //set object positions
        if ( ttype == Transition.FromOldSelection )
            local index = -floor( count / 2 )
            for ( local i = 0; i < objects.len(); i++ ) {
                objects[i].index_offset  = index
                index++
            }
    }
}

local menu = GameMenu( 50, 50, 900, 200, 5 )

This is a more simplistic "custom object" - it creates its on surface, it creates the objects on that surface, and when the game changes, it adjust the objects index offset. You'd have to do more if you wanted to animate them and so forth. Even this is not complete, as you need to handle scenarios like list changes, etc... but hopefully that gives you an idea on what can be done.

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Move game selection like a menu
« Reply #5 on: January 30, 2017, 08:13:39 PM »
this is what looking for ,, but just with spacing control. and added frame .png that can move L & R to select game..like grid.

amazing.. thanks
help a friend....