Help With a Text Box

Just started using Construct 2? Post your questions here

Post » Sat Apr 23, 2016 4:13 pm

Hey guys!

I've been learning to use Construct 2 for the last couple of months and really enjoyed my time with the software. I'm currently going through Jerementor's absolutely wonderful "Platform Mini-Series" tutorial on Scirra's YouTube channel. His way of making a text box with AJAX and XML looks really neat, but the problem is... I can't get it to work.

The way it should work is this. When player is overlapping a sign, an invisible layer with a text box is made visible. The text box slowly fills with text from an XML file. I can get the box to appear, but not the actual text. I'm currently still using the free version of C2, but I don't think that should have an effect here.

I've gone through my code line by line until I just gave up and made a testing project with the relevant parts copied straight from Jerementor's example capx, and I still have the problem. If anyone could nudge me towards the solution, I'd be really grateful! Even a hint would be appreciated, as right now I'm feeling quite frustrated with this. Thanks!

Since this is my first post on the forum, I can't post any links. You can still download my capx from Dropbox or check out the event sheet (it's quite short) on imgur, you just have to fill the latter part of the address line yourself.

To get the capx, go to Dropbox and then add this to the address line: /s/1nyuadxf2knhvf9/Textbox_test.capx?dl=0
Or to see event sheet, go to Imgur and add this: /lngNzcw
B
5
Posts: 7
Reputation: 262

Post » Sat Apr 23, 2016 6:27 pm

I dont understand the logic in your cap.

On overlap you make the AJAX plugin request a file. But you never wait for the file to end loading. Yeah in the code you do. But in reality, the overlap keeps happening, the instance variable will not change, so the request to load the file will happen again and again before the file is loaded. The event 'on instructions loaded' will never ever trigger.

This happens because you did not follow the tutorial. Read it all over here: https://www.scirra.com/tutorials/807/ho ... -game-talk

The basics are simple though.

1/ Let the AJAX plugin request the file only once in the whole project. Preferable 'on start of layout'.
2 / Wait for the file to complete loading, only once in the whole project . Preferable in a root event. Assign the data to the XML plugin.

Now you can ask the XML plugin questions, and it wil answer. It wil keep the data till you change them. No need to asign them over and over again.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Apr 23, 2016 7:57 pm

I realised later the xml is really small. And that it did not load even when not colliding.
So there had to be something more beeing wrong. I checked your xml, it is not formatted right.
Here as it should be:

https://
drive.google.com/open?id=0B1SSuCVV8v74NTh6b2EwWUhKejA

Still, my previuous comments are still valid.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Apr 23, 2016 8:34 pm

Hey 99Instances2Go, thank you so much! I got it the basic idea to work by using your fixed xml and following the tutorial you linked.

As I said, the capx I posted is pretty much a straight copy of a video tutorial found on the Scirra YouTube channel. This is the first time I've tried to use XML in C2, so I wasn't sure at all if it was weird or not. The bad formatting of the XML file was of course just my mistake. Thanks again for putting me on the right path with this.
B
5
Posts: 7
Reputation: 262


Return to Beginner's Questions

Who is online

Users browsing this forum: banquetburger and 5 guests