Rayj

Sending PHP data to PIXI Javascript

Recommended Posts

I have a small PHP script that pulls some data out of a database. There are two parts to the data, a string variable and an integer. (ex: Chevy 22.55)

I want to pass these to PIXI Javascript in order to display them like this:

Chevy

22.55

Note:  No space after Chevy.  I don't know why posts are double spaced in this forum?

Thanks,

Ray

Share this post


Link to post
Share on other sites
2 minutes ago, ivan.popelyshev said:

Well, first step is to learn javascript for a day. Then you'll come to solution :) Unless you already did that and have a solution that somehow is not working, which we actually can help you with.

Learning JS will not tell me how to pass data from PHP to Javascript.  I've taken multiple Javascript tutorials.  Not one mention of PHP.

Share this post


Link to post
Share on other sites

Ah, so that's ajax problem.

loader.add('mylevel', '/scripts/stuff.php');
loader.load(function(loader, resources) {
    parseLevel(resources.mylevel.data); //or .text, i really dont remember, please look in this object what it gives you;
});

Loader is the same as for your resources: https://github.com/kittykatattack/learningPixi#displaying-sprites

If you want to load new level after you already called "load", please just do 

loader.add('mylevel2', '/scripts/stuff.php?id=2', function(loader, resource) {
    parseLevel(resource.data); //or .text, i really dont remember, please look in this object what it gives you;
});

and parseLevel is your function that makes level from that txt stuff

Share this post


Link to post
Share on other sites

Maybe is about php and java browser how is working.

Youu have a start here: http://stackoverflow.com/questions/25093905/when-and-where-does-javascript-run-how-about-php-can-i-combine-the-two

Also depends the structure of data over browser or server communication.

This is my opinion. I'm not very good of that. Nice question. :)

 

Share this post


Link to post
Share on other sites
1 hour ago, Rayj said:

I think using JSON.encode is doing the trick for me.

Now have to figure out how to make my code reiterative.  The integer will be changing fairly often.

OK, now we have an information we didnt have before: you need update it in realtime, and not just per stage or per level. Find a comet library for PHP and JS.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.