[Behavior] scrolling (for text/sprite font plugin)

Post your completed addons to share with the community

Post » Mon Mar 23, 2015 8:44 am

Apparently we can't attach .capx files at the moment.

In the meanwhile:
My original idea was to use an external .txt file (imported with AJAX) for the contents of the "Text" field:
Code: Select all
System | On start of layout | AJAX | Request Text.txt (tag "Text")
AJAX | On "Text" completed | Text | Set text to AJAX.LastData


What do I need to do, to use this kind of text contents in place of the current number lines (1-100)? Or, in that matter, how do I add any kind of text, in place of the numbers that appear in the beginning of each line? :)
B
5
S
1
G
1
Posts: 7
Reputation: 368

Post » Mon Mar 23, 2015 3:59 pm

I just received a message from Scirra's support and apparently it will take them a while to fix the file attachments.

Can I have your e-mail to share you my project via Dropbox/Drive?
B
5
S
1
G
1
Posts: 7
Reputation: 368

Post » Mon Mar 23, 2015 4:33 pm

Removed
Last edited by rexrainbow on Tue Mar 24, 2015 2:00 pm, edited 1 time in total.
B
97
S
22
G
179
Posts: 4,125
Reputation: 104,557

Post » Mon Mar 23, 2015 5:21 pm

Alright, I shared it -
Code: Select all
https://drive.google.com/open?id=0B7ZNd5mnNO7TNXkzMVRkREdxcjQ&authuser=0
B
5
S
1
G
1
Posts: 7
Reputation: 368

Post » Tue Mar 24, 2015 3:32 am

@VaeVictus

You might assign wrong image point name "UP". So that the boundaries would be incorrect.
It should be "TOP" in your test case.
B
97
S
22
G
179
Posts: 4,125
Reputation: 104,557

Post » Tue Mar 24, 2015 10:14 am

Thanks a lot. And sorry for wasting your time, it was really just a typo on my part. I'm embarrassed.

I'm trying to understand what each event does to get a grasp of how the whole thing works. Can anyone verify my assumptions and answer my questions?

Code: Select all
Global text content = ""

1. We add a global variable "content" of the text type. I don't understand what is this used for since I don't see it ("content") referenced anywhere else in the event sheet. What is it's role?

Code: Select all
 System | On start of layout
-> System | For "i" from 1 to 100 | Text | Scrolling Append str(loopindex("i")) & newline

2. On start of layout we do nothing but run sub-event which creates a loop which repeats 100 times, each time appending a number (the line's index) and creating a new line into the "Text" object. How do I append an actual paragraph of text to appear in the "Text" object instead of these indexed lines?

Code: Select all
 System | On start of layout | Thumb | Set Boundary vertical boundary to | bar at image point ["UP, "DOWN"]
                                                             | Thumb | Set position to | bar (image point "UP")

3. Here we limit the movement of "thumb" by pinning it to the bar and preventing it from going outside of the two image points - up and down. Here, we also set initial position of thumb to the up image point.

Code: Select all
 System | On start of layout  - or -  thumb | Is DragDrop2 dragging | Text | Scrolling Scroll content by percentage to thumb.Boundary.VerPercent 

4. Here we make the text actually scroll when we drag the tumb up and down by a percentage of the vertical length of the boundary. What I don't understand is the "system | on start of layout" part - why do we need this?
B
5
S
1
G
1
Posts: 7
Reputation: 368

Post » Tue Mar 24, 2015 10:37 am

@VaeVictus

1, 2
Global variable "content" did not be used in this capx, but I forgot to removed it. Here uses for loop to create content listed in 2.
You might use "Action:Set content", or "Action:Append content" of this behavior to set the content.



4.
"condition: on start of layout" just scrolls to current percentage of content. It assumes that thumb might not at position of percentage 0.
B
97
S
22
G
179
Posts: 4,125
Reputation: 104,557

Post » Sun Mar 29, 2015 6:16 am

Update

- Fix bug while scrolling after append content immediately.
- Add current content, visible lines count, total lines count, current start line index message shown at debug panel.
B
97
S
22
G
179
Posts: 4,125
Reputation: 104,557

Post » Sun Jul 12, 2015 6:09 pm

@rexrainbow i am also stucked with setting up boundary for the "thumb" sprite.. I have exactly copied your code, but still no luck , will you please look into my file and let me know
I can't upload hyperlink... is their any way i can send the file to you?
B
3
Posts: 3
Reputation: 181

Post » Mon Jul 13, 2015 3:11 am

@rumanbsl

You could send a link under this page.
B
97
S
22
G
179
Posts: 4,125
Reputation: 104,557

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests