Posted: 2nd Feb 2022 13:55
I am scrolling my menu up and down

Text and sprites together

This works real good, no problems

How do i stop them from scrolling after you get to a point?

Here is my simple scroll code

I tried something like

if ytextpos<0 then SettextPosition(level_select_text[x],xtextPos,ytextPos+5)

But this only does it for one text not all, they all scroll to 0 then stop all behind each other.

+ Code Snippet
Wheel=GetRawMouseWheelDelta()

if GetRawMouseWheel()&lt;&gt;0
xtextPos=gettextx(level_select_text[x] )
ytextPos=gettexty(level_select_text[x] )
SettextPosition(level_select_text[x],xtextPos,ytextPos+Wheel)
endif
Posted: 2nd Feb 2022 14:43
It only works for one because you are only asking it to do it for one - specifically the one refenced by x in the array.
If you want to perform the task on all text objects then you need to loop through the text array and perform that task on all of them.
+ Code Snippet
Wheel=GetRawMouseWheelDelta()
 
if GetRawMouseWheel()&lt;&gt;0
	for x = 0 to level_select_text.length
		xtextPos=gettextx(level_select_text[x] )
		ytextPos=gettexty(level_select_text[x] )
		SettextPosition(level_select_text[x],xtextPos,ytextPos+Wheel)
	next x
endif
Posted: 2nd Feb 2022 15:21
Ok I did this

+ Code Snippet
Wheel=GetRawMouseWheelDelta()
  
if GetRawMouseWheel()&lt;&gt;0
    for t = 0 to level_select_text.length
        xtextPos=gettextx(level_select_text[t] )
        ytextPos=gettexty(level_select_text[t] )
        SettextPosition(level_select_text[t],xtextPos,ytextPos+Wheel/5)
      
        if ytextpos=0 then SettextPosition(level_select_text[t],xtextPos,ytextPos+5) //added this line to stop scrolling
        
    next t
endif


and this is what happens, there all stopping at 0

Posted: 2nd Feb 2022 16:25
Ok, I figured this out.

I had to make a single out of array text and sprite and get there pos for y

then if there y is out of bounds make the whole array stop moving or reposition.

here is my solution.

+ Code Snippet
Wheel=GetRawMouseWheelDelta()

getleveltexty=gettexty(level_select_text[1] )  

if GetRawMouseWheel()&lt;&gt;0
    for t = 0 to level_select_text.length
        xtextPos=gettextx(level_select_text[t] )
        ytextPos=gettexty(level_select_text[t] )
       if getleveltexty&gt;5 then SettextPosition(level_select_text[t],xtextPos,ytextPos+Wheel/5)
      if getleveltexty=5 then SettextPosition(level_select_text[t],xtextPos,ytextPos+5)
      
     
      if getleveltexty=25 then SettextPosition(level_select_text[t],xtextPos,ytextPos-1)
      
    next t
endif
Posted: 2nd Feb 2022 19:32
Your first solution, which you say sets every text objects y position to zero (actually sets them to 5) does so because of this:
+ Code Snippet
ytextPos=gettexty(level_select_text[t] )
if ytextpos=0 then SettextPosition(level_select_text[t],xtextPos,ytextPos+5) //added this line to stop scrolling

In that you are checking if the y position of every text object is zero and then adding 5 to it. You are doing that in a loop which updates every text object that has the ID of [t]

A better solution would be to check the y position of the first text object before the loop. Like this:
+ Code Snippet
Wheel=GetRawMouseWheelDelta() 
   
if GetRawMouseWheel()&lt;&gt;0 and GetTextY(level_select_text[0]) &gt; 0
    for t = 0 to level_select_text.length
        xtextPos=gettextx(level_select_text[t] )
        ytextPos=gettexty(level_select_text[t] )
        SettextPosition(level_select_text[t],xtextPos,ytextPos+Wheel/5)         
    next t
endif
Posted: 3rd Feb 2022 0:36
Ok I tried this and it works but then when I scroll up to 0 I can not longer scroll.
Posted: 3rd Feb 2022 4:51
related is this scrollbox example where the premise is to limit the text (or menu in your case) to specific bounds at the top and bottom.

i can't visualize how your menu is supposed to look from the screenshot but if you have multiple elements (vs 1 like my text object), set a max top and max bottom, regardless.

you could also just set a limit to the topmost object and use it as a reference for all subsequent objects.

note, you may also want to use the scissor commands as in that example if you're not already
Posted: 3rd Feb 2022 9:00
Ok I tried this and it works but then when I scroll up to 0 I can not longer scroll.

That is to be expected.
I wrote that code to match the specification that you asked for - to stop it scrolling when it reaches zero.
I could rewrite it to match your new request but if I keep writing code every time you want the slightest change then you are not going to learn anything, and I would be the one to have written your game.

I'm still happy to help though, so I'll talk you through why it doesn't move after getting to zero and suggest some ways to change that.

So firstly, why does it no longer move when it gets to zero?
Let's assume that the uppermost text object (level_select_text[0]) has a Y position of 4. When it gets to this line:
+ Code Snippet
if GetRawMouseWheel()&lt;&gt;0 and GetTextY(level_select_text[0]) &gt; 0 

We ask: Has the wheel moved in any direction (this is important later) and is the text object level_select_text[0] 's Y position greater than zero?
Yes to both, so we continue and loop through all text objects updating their Y position.

Now, lets assume that the wheel has moved enough to move the text objects 5 units up. The next time through the loop text object level_select_text[0] 's Y position is -1. So when we get to this line again:
+ Code Snippet
if GetRawMouseWheel()&lt;&gt;0 and GetTextY(level_select_text[0]) &gt; 0 

Has the mouse wheel moved? Yes
Is text object level_select_text[0] 's Y position greater than zero? No
So we skip the loop and don't update the position of any text object.

That's why it behaves the way it does. So how to fix that so that it is still able to move down?

At the moment you are checking to see if the mouse wheel has moved with no care about which direction it has moved.
A simple solution would be to ensure that the loop to move the text objects only occurs if the text object level_select_text[0] 's Y position is greater than zero and the mouse wheel has scrolled upwards.
Once you have that, you can see it's a very small step to also stop scrolling in the other direction when some maximum value is reached.

One final thing to mention:
You are checking and moving the text based on GetRawMouseWheel() So if you move the mouse wheel one click, it's value will change and remain changed, moving the text objects up every frame.
Instead you should be using GetRawMouseWheelDelta() which only returns the amount the mouse wheel has moved since the last frame. The value will be very small and you will probably need to multiply it by some value to move your text.