Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Scrolling text objects example failing

Author
Message
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 30th Dec 2023 05:25 Edited at: 30th Dec 2023 05:27
Hi, I am trying to make a scrolling text example with 2 text objects and keep track of their "y" positions using an array when the respective buttons are pressed. Arrays are a serious weak point for me. My brain goes on overload just looking at arrays.

For my example I have a text file named Team.txt with the following text inside:
Player 1
Player 2

I want the text to be put into the 2 text objects that are displayed on the screen. For the "UP" button I want the text to move down the screen like you are scrolling to the top of a list and the "Down" button move the text up like you are scrolling down the list

Gigabyte Board/ AMD 3.3 Ghtz Quad core/8GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

Zaxxan
AGK Developer
3
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 30th Dec 2023 13:47 Edited at: 30th Dec 2023 16:37
You are incrementing t_obj but within that loop you have another loop that creates the text twice (y250 and y 350) with the same id.

If you move the createtext from the second loop and put it in the first loop you will not get the error
JosephB
17
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 30th Dec 2023 14:08
As @Zaxxan noted you have two for loops creating the same text object number. There are also some array errors as well. I did not want to work with reading a file, so I commented that out of your code and then tried to simplify your code a little to show the arrays.



Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 30th Dec 2023 15:21 Edited at: 30th Dec 2023 15:34
@Zaxxan
Yes, I understand it sees that the same ID is being assigned to both text objects, but the for/next loop should be incrementing T_Obj by 1 each loop with the way I have it set up. How the for/next loop could be assigning the same ID to both text objects I don't see it

@JosephB
I knew the array stuff was screwed up. I understand arrays if they are basic(no pun intended) and I can understand a more complex one if there is an explanation of what is going on to read, but when I try to set up a complex array and setting it up the way it is in the example my brain gets fried because the example is never set up for my situation. Thank you for your snippet, I will read the remarks and try to see and understand what is going on. Arrays screw with my head, but for what I am trying to do with my program I am going to need a bunch of massive arrays ugh lol. I will need use text files to load the information into the text objects, because it will take way to long to type all 30,000 player names and attributes in code. I was just using the "Player 1", and "Player 2" as an example to try to set some basic example up that I could get started with and modify as I go for things. This scrolling text will be for like the team roster among other things.
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 30th Dec 2023 15:46 Edited at: 30th Dec 2023 15:59
This post has been marked by the post author as the answer.
I checked the position of the text objects set by the code and they should not be showing up as they are in the image. They are offset, player 2 is slightly to the right more. Why is this happening?

[Edit Never mind I figured out why it was happening. In the text for the array to insert the "Player 2" had a space between the first double quotes and the text as such: " Player 2"
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.

Attachments

Login to view attachments
JosephB
17
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 30th Dec 2023 15:50
That was an accidental space I added before "Player 2" when I typed the line: Text as String [1] = ["Player 1", " Player 2"] //two strings, Text[0], Text[1], for the text objects TxtObj[0] and TxtObj[1]. Delete that extra space and all should be fine.
Zaxxan
AGK Developer
3
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 30th Dec 2023 16:39 Edited at: 30th Dec 2023 16:40
@unseen ghost Within the t_obj loop you have another loop that creates the text object twice (y250 and y350) using the same ID
Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 30th Dec 2023 17:01
@Zaxxan
I will look harder at my original code and go step by step through it to see.

Currently I see that the only variable that seems to be setting T_Obj variable is the outer For/Next loop. The inner one is only suppose to set the "y" coordinates for each text object.

I will try to set up another example to see if I can do it without getting the error. I'm just not seeing it. Usually I see something like that fairly easy.

The only thing I can come up with is that the inner loop causes the outer loop to create 2 text objects with the same ID. If that is correct, I really had to follow the code slow to see it
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Zaxxan
AGK Developer
3
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 30th Dec 2023 18:41 Edited at: 30th Dec 2023 18:42
This creates the text object twice using the same T_obj value

Zaxxan
AGK Developer
3
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 30th Dec 2023 18:47 Edited at: 30th Dec 2023 18:55
Try this

Unseen Ghost
21
Years of Service
User Offline
Joined: 2nd Sep 2002
Location: Ohio
Posted: 30th Dec 2023 22:34 Edited at: 30th Dec 2023 22:35
Quote: "Try this"





I tried it and had to make some other adjustments for there not to be any errors. Problem is, is that no text showed up, just the buttons. I will have to make other changes to the other part of my code(left over original code) with the above snippet to get it to work properly. My array stuff in original code is all wrong and fails to do the job. I suck at arrays lol
ASRock motherboard/ AMD 4.1 Ghtz Duel core/16GB Ram/Nvidia Geforce 1080 GTX 8GB/1TB Western Dig. SSD/Windows 10 Home/Dark Basic Pro 9Ex/AGK2/AGKStudio

No one cares how much you know until they know how much you care.
Zaxxan
AGK Developer
3
Years of Service
User Offline
Joined: 17th Nov 2020
Location: England
Posted: 30th Dec 2023 22:51
Keep trying, I'm sure you will solve it.

Login to post a reply

Server time is: 2024-04-28 18:51:56
Your offset time is: 2024-04-28 18:51:56