Post new topic    
Page «  1, 2, 3, 4  »
Slime
Send private message
Test results 
 PostSun Aug 23, 2020 5:27 am
Send private message Reply with quote
As always thanks a lot for your answers.
So I've tried to implement the script and here are the results

First a picture of my slice tree. Could you please tell me if I attributed the look up code correctly? Is it necessary to make slice a parent and others children? (text & selection area
may be...)



The hss compile and can be imported. When I test the script doesn't launch properly.
I've got those messages from the debugger:







Could you please help me with getting rid of these errors?
Metal King Slime
Send private message
 
 PostMon Aug 24, 2020 2:07 pm
Send private message Reply with quote
Oh sorry, I didn't explain how to set up the slice tree. It should look like this:

Code:

Rectangle    menu items
  Sprite   menu cursor
  Text
  Text
  Text

The position of the cursor doesn't matter, as long as it's a child of the "menu items" slice.
If you want, you could use a separate Container slice instead of reusing the Rectangle slice for that. Or not have a "menu items" slice at all, and just leave all the Text (menu item) slices at the top-level of the slice tree (you would have to write "menu items := collection" in the script).

You had Select slices in your tree, but I guess that you don't know how to use them, because they're useless if they have no children. You could definitely use them for a menu, but the script I posted doesn't. Seelct slices woudl be useful if you created two versions of each menu item, one highlighted and with cursor next to it, and one not. That's simpler, but more work than just having one copy and changing its appearance with a script.
Slime
Send private message
 
 PostTue Aug 25, 2020 6:13 am
Send private message Reply with quote
Thanks your answer TMC!

I reorganised the slice tree and make the cursor sprite children.
By the way there are no place to specify that such slice collection part is a
parent, so I assume they are parent by default.

Another thing that I don't fully understand are the errors the debugger pointed out. What do they mean?
It seems to be linked with slice position and text color...

What should I check to get rid of them? The slice tree? The script?
Liquid Metal King Slime
Send private message
 
 PostTue Aug 25, 2020 11:33 am
Send private message Reply with quote
All those error messages mean you used spice commands on an empty variable.

The value of the variable was 0 instead of being a slice handle
Metal King Slime
Send private message
 
 PostTue Aug 25, 2020 4:02 pm
Send private message Reply with quote
Do you mean you still get those errors? It looks like the "sl" variable is 0. So make sure that the "menu items" slice has at least 3 children, and "selection" is a value between 0 and 2.
I don't know what you mean by "By the way there are no place to specify that such slice collection part is a
parent"

Sorry again, I just realised I made a mistake. (I haven't tested the script myself.) Actually, because of the line "sl := slice child (menu items, selection)", it means the three text slices need to be the first 3 children of the 'menu items' slice, e.g. like
Code:
Rectangle    menu items
  Text
  Text
  Text
  Sprite   menu cursor

or
Code:
Rectangle    menu items
  Text
  Text
  Text
Sprite   menu cursor
Slime
Send private message
Sorry to ask that basic slice question but... 
 PostSat Aug 29, 2020 7:31 am
Send private message Reply with quote
I'm sorry to ask such a basic questions Confused about about slices but ....

How to make a parent slice
If I'm not mistaken you have to use to indicate that you want to slip chidren slice


How to make a child slid?
-> is there a line a option (for example "slice type: child/ slice type: parent )

What is the child auto sort option for?

What is parent fill yes option for?

I'm new to slice collections so...
Anyway as always thanks in advance for the answers and special thanks to James & TMC for their answers.
Liquid Metal King Slime
Send private message
 
 PostSat Aug 29, 2020 1:56 pm
Send private message Reply with quote
In the slice editor, there is no menu item for parent.
You need to select the slice, and then hold shift and press the right arrow key.

The selected slice will be indented to the right. It will become the child, and the parent will be the slice above it
Slime
Send private message
How do I use slice look up code for several things 
 PostSun Aug 30, 2020 3:12 am
Send private message Reply with quote
Thanks Bob the Hamster! I managed to put them children using Shift and the -> key and it worked.

I would like to try to translate my game in japanese.

So the test slice "details" would became a group of 6 box border sprites
デ ィ テ ィ ー ル

The text slice "card" would became a group of 3 box border sprites
カード

And the text slice "end" would became a group of 3 box border sprites
エンド

I would like to create a group a 6 slice sprite elements and 1 group of 3 and another group
of three box edge sprite element and make them affected the same way the text slice did in the script. One whole group would be affected by sprite palette change (to create selection
effect on screen) at the same time.

Is it possible to do this? How do I create "groups" in a slice collection?

As always thanks in advance for the anwers
Liquid Metal King Slime
Send private message
 
 PostSun Aug 30, 2020 6:05 pm
Send private message Reply with quote
I recorded a video demonstrating how to use slice parenting to group together sprites in a container

Slime
Send private message
Thanks for the video 
 PostMon Aug 31, 2020 6:48 am
Send private message Reply with quote
Thanks for the video Bob The Hamster! I was really useful. May be we should create video tutorial and update them in the wiki.... A container with sprites in it is exactly what I need.

Now all the left are the command line to alter the sprites at the same time.
Just like the rectangle and the text lines, I think I need to use a look up code for the container.

The question is should I put all the sprite in the same container and alter them, but It would make me use a look up code for each characters...

For a start, I think I should make a 3 containers. One with white sprite letter, one with light yellow sprite and the third with lemon yellow sprite. (It is works, I may double it for more natural highlight effet)

2 containers would be invisible most of the those and I would use the look up slice to alter
with container & sprite is visible.
So could you tell me what command should be used to turn a container (and its elements) invisible?

As always thanks a lot for the help!
Metal King Slime
Send private message
 
 PostMon Aug 31, 2020 3:41 pm
Send private message Reply with quote
You can make a slice visible/invisble with "set slice visible (sl, true)" and "set slice visible (sl, false)"

But you said you want two containers to be invisible and the third visible. This can be done using a Select slice. Just one child of a Select slice is visible, the others automatically become invisible. You use "set select slice index" (or "set selected child") for that:
Code:
Select   # This is a single menu item
  Container
    Sprite    # One of the characters
    Sprite
    # etc
  Container
    Sprite    # One of the characters
    Sprite
    # etc
  Container
    Sprite    # One of the characters
    Sprite
    # etc

Write "set select slice index (sl, 0)" to make the first visible and other two invisible, "set select slice index (sl, 1)" to make the second visible, etc.

However! It's a lot of work to create all those slices; there's a much easier way. Don't create three copies of the text, just have one copy, and use the following script which changes the palettes of all the sprite children of a slice:
Code:
script, change child palettes, parent, palette, begin
  variable (child)
  child := first sprite child (parent)
  while (child) do (
    set sprite palette (child, palette)
    child := next sprite sibling (child)
  )
end


So if your slice collection looks like this:
Code:
Rectangle    menu items
  Container     # This is the first menu item
    Sprite    # One of the characters
    # etc
  Container
    Sprite    # One of the characters
    # etc
  Container
    Sprite    # One of the characters
    # etc


Then you can write:
Code:

 sl := slice child (menu items, selection)  # Slice for new selection
 change child palettes (sl, 2)

(The first line of code is from the script I posted earlier)
Slime
Send private message
New slice collection 
 PostWed Sep 02, 2020 5:39 am
Send private message Reply with quote
So, I used a free collection slice and re-created the menu. I've assignated menu items to the containers.
What left are the command which with a lookup code, can act on the childrens... I wonder if
it possible... Confused



How should I modify the previous script to make it exactly do the same?

Code:

variable (collection, menu items, cursor selection, sl)
collection := load slice collection (1)

# Now we need to get the slice that's the parent of all the menu items.
# I assume it has the "menu items" lookup code
menu items := lookup slice (sli: menu items, collection)

# And the menu cursor slice too, lookup code "menu cursor"
cursor := lookup slice (sli: menu cursor, collection)

  variable (child)
  child := first sprite child (parent)
  while (child) do (
    set sprite palette (child, palette)
    child := next sprite sibling (child)
    )
    break  # exit
  )

  # First change the currently selected slice to deselected appearence
  # (for simplicity, do this even if the selection doesn't change)
  sl := slice child (menu items, selection)  # This is the slice for the (previous) selected item, which I assume is a text slice
  set text color (sl, 15)  # Change this to normal text colour!

  # Change the selection
  if (key press(left key) || key press(up key)) then (selection -= 1)
  if (key press(right key) || key press(down key)) then (selection += 1)
  if (selection == -1) then (selection := 2)  # wrap around from first to last
  if (selection == 3) then (selection := 0) # wrap around from last to first

  # Then update the selected menu item to correct appearance
  sl := slice child (menu items, selection)  # Slice for new selection
 
  #set text color (sl, 12)  does not work anylonger
  # What commands should go here?
  # sl := slice child (menu items, selection)  # Slice for new selection
  #change child palettes (sl, 2)

  # Move the cursor
  put slice (cursor, slice x(sl) -- 30,  slice y(sl))

  wait
)
free slice (collection)


Anyway, as always thanks for the help and feel free to comment
Metal King Slime
Send private message
 
 PostWed Sep 02, 2020 10:42 am
Send private message Reply with quote
You should have only one slice with the "menu items" lookup code, which should be the parent of the three menu items:
Code:
Sprite   # The cursor
Rectangle    menu items
  Container     # This is the first menu item
    Sprite    # One of the characters
    # etc
  Container
    Sprite    # One of the characters
    # etc
  Container
    Sprite    # One of the characters
    # etc
Slime
Send private message
It works! But what happened to the cursor? 
 PostFri Sep 04, 2020 5:48 am
Send private message Reply with quote
I tested my script and it works very well.

Here is the new version of my slice tree



But there's something strange: When I test the game my cursor does not appear



Does anyone has idea about it could that come from?

Thanks for help! I would have taken much more time and efforts if I had tried to do all on my own!
Metal King Slime
Send private message
 
 PostFri Sep 04, 2020 3:39 pm
Send private message Reply with quote
You parented the menu cursor to one of the menu items! That's a problem, because it means "change child palettes" will change it too. Move it completely outside of "menu items".

Try changing the line
Code:
  # Move the cursor
  put slice (cursor, slice x(sl) -- 30,  slice y(sl))

to
Code:
  put slice screen (cursor, slice screen x(sl) -- 30, slice screen y(sl))
Display posts from previous:
Page «  1, 2, 3, 4  »