Slice Menu Example

Upload your games here. Download other people's games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7661
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)

Slice Menu Example

Post by Bob the Hamster »

A little tutorial script showing how to make a simple menu using a slice collection

Scripts are included in the zip file, but here they are again

Code: Select all

define constant(18, second)
global variable(1, my choice)

plotscript, my event with a choice, begin
  my choice := choose a thing
  show text box(1)
  wait for text box

plotscript, choose a thing, begin
  col := setup choose a thing
  variable(holder, cursor)
  holder := lookup slice(sli:choice holder, col)
  cursor := lookup slice(sli:cursor, col)
  variable(sl, need update)
  sl := first child(holder)
  result := -1
  need update := true
  while(true) do(
    # Input
    if(keypress(cancel key)) then(
      result := -1
    if(keypress(use key)) then(
      result := slice child index(sl)
    if(keypress(right key)) then(
      sl := next sibling(sl)
      if(sl == none) then(sl := first child(holder))
      need update := true
    )elseif(keypress(left key)) then(
      sl := previous sibling(sl)
      if(sl == none) then(sl := last child(holder))
      need update := true
    # Update
    if(need update) then(
      set slice width(cursor, slice width(sl))
      set slice height(cursor, slice height(sl))
      move slice to screen pos(cursor, slice screen x(sl), slice screen y(sl), second / 3)
      play sound(sfx:select8bit)
      need update := false

  cleanup choose a thing(col)

script, setup choose a thing, begin
  suspend player
  exit(load slice collection(0))

script, cleanup choose a thing, col, begin
  free slice(col)
  wait(second / 4)
  resume player

slice_menu_example0000.png (4.17 KiB) Viewed 2764 times
(1.92 MiB) Downloaded 290 times
Post Reply