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 / DrawText in a loop? Tier 1

Author
Message
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 17:59 Edited at: 23rd Aug 2018 18:11
So I'm attempting to draw a bunch of strings from an array as a list using DrawText() inside of a loop.
I have set up a text object, which is formatted to look the way I want the list entries to look.

Now with Sprites, you are able to draw a sprite multiple times using a loop so I fugred that the same using drawText too should be possible.



But the only thing that happens is that the text line just gets drawn at the last offset position.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 18:27 Edited at: 23rd Aug 2018 18:41
I've made a video demo if the issue:


EDIT

As a matter of fact, it seems like even by copying and pasting the code like this:



only draws the last rendition of the code, making it seem that you indeed cannot use DrawText in a loop to draw multiples of the same text...
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 23rd Aug 2018 18:51 Edited at: 23rd Aug 2018 18:52
your only accessing the last element of your text array
is this what you want to do
fubar
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 18:58
Do you have to clear screen before Every instance where you use a draw command? So If I draw 5 sprites myself all in different parts of the code (not all together) then I have to:
1) Clear Scree
2) Draw
3) Render
4) Swap
?

or is Render and Swap basically replace Sync()?
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 19:05 Edited at: 23rd Aug 2018 19:15
Also you've put in the loop variable Num in as the ID of the Text object in the all of the text commands.
I only created 1 text object though and it has it's own id stored in the variable called txt_array_size. So If the array size is 10 then the loop will try to look for TextObject IDs 1 to 10, which do noti exist. I don't really get that.

EDIT1:
Also

Seeems like size is not a valid array function for checking it's size . What was wrong with Length?
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 23rd Aug 2018 19:25 Edited at: 23rd Aug 2018 19:26
Quote: "Seeems like size is not a valid array function for checking it's size . What was wrong with Length?"

It works for me so you just mixed up .size with .length
So you solved it right ?

Smooth looking GUI
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 19:33 Edited at: 23rd Aug 2018 19:35
Unfortunately not really I'm still working it out.
However now that i think about it, each list entry should also have an edit and skip buttons so perhaps It would be easier to create a list entry as a type (sort of like an OOP method) so each entry has it's own Text entity , string for that text entity, x,y and the two buttons. then it's just a matter of spawning a new object / type.

I kinda wish I was successful in setting up Android in Tier 2. I'd honestly be much more comfortable in C++ there, but alas I couldn't seem to set up up so Tier 1 worked right away.

PS: also thanks

I have no idea how you guys are managing to get .size to work because I see it nowhere in the docs:
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
puzzler2018
User Banned
Posted: 23rd Aug 2018 19:52 Edited at: 23rd Aug 2018 20:00
Hello

You just using 1 ID (txt_array_size) as the text object -- which will indeed only produce one outcome

If you with to add text IDs to have multiple text objects then you will need an empty array and add the text objects each time you add a new task


like:-

TextID as integer[]

and then when creae a new task to use TaskID.insert (createtext ( "task message") )

and then the loop



If you have solved it then apologies but this is how i would do it


Something like this:-

Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 20:04
This is actually what I'm doing right now.

The issue right now wasn't to create a separate text object for every array entry but to draw the same text object again and again.
With sprites, folks say that they can create 1 sprite and draw it multiple times. if you need to draw a 100 bricks, you don't need to create or clone a 100 sprites, Just draw 1 sprite in a loop a 100 times while changing the position of the sprite as you wish before calling the draw function.

I assumed I could do the same with text objects, just changing the text string contents before drawing.
It does not seem to be the case, and I have to create a separate text object for each list entry.

I was also successful in populating one string with all entries, separated with chr[10] which is a carriage return character, thus simulating a list but it's not really what i'm looking for.
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net
puzzler2018
User Banned
Posted: 23rd Aug 2018 20:10 Edited at: 23rd Aug 2018 20:12
Oh I see - thanks for clarifying

How about this, is this the principle your looking for

janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 23rd Aug 2018 20:13 Edited at: 23rd Aug 2018 20:15
Try to recreate your scenario in a new project, you will see it works as you say with draw text.
No Render or swap needed
No new text objects needed
Just as you described above but please don't try .size as it's not a default property in AGK
Drawing instances works with Objects,Sprites and Text... as they are pretty much the same in the render pipe.

@puzzler2018: Aww needed 3 mins to write this text
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 23rd Aug 2018 20:39 Edited at: 23rd Aug 2018 20:40
yeah, ended up just creating a separate text object for each entry, it works, I can move on now.
Thanks for the help fellas
Eisenstadt Studio: Eisenstadtstudio.com
Composers Page: Milesthatch.net

Login to post a reply

Server time is: 2024-04-24 07:49:13
Your offset time is: 2024-04-24 07:49:13