Robsta's Forum Posts

  • So I've read the documentation about sprites and ajax objects, but I'm still a little baffled on how to load an image to a sprite from a different domain.

    Part of this bafflement is that if I write:

    <img src="http://crispme.com/wp-content/uploads/88456.jpg?pass" alt="Smiley face" width="420" height="420">

    In an html file in the same location as my construct 2 project, it works just fine, but if I try to load the image (http://crispme.com/wp-content/uploads/88456.jpg?pass) it doesn't work, nor does it come up with an error in the console log.

    Does HTML have some way around this cross-domain permissions thing? But the more important question is how would I be able to load an image into my game cross-domain?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi, I'm Robert

    I'm a C++ programmer made web-programmer by means of the marketplace. I found out about Construct 2 because I believe html5 is the way of the future of mulch-platform browser gaming, and in my search for the best html5 engines, Construct 2 was one of the ones I found.

    I found that I could make rapid prototypes in Construct 2, even though I didn't feel like I was using the extent of my programming skills, it's a good step towards web development. Then I started looking at plugin development for Construct and felt more at home in a code-like environment.

    My current Construct project is to make a plugin that fully integrates the Synaptop API into Construct so that I can create games and apps in this engine and run them with full Synaptop functionality.http://www.synaptop.com

  • What appears to be the problem is that I want asynchronous events to be called synchronously, which it appears is impossible, so I made a workaround for it (called the asynchronous event every time the value I want to return can change).

    The plugin and getting it to work on other computers is a little complicated to be posting (or parts there of). But I did find a workaround for this specific instance. Hopefully I won't need to use synchronous events much in the rest of the plugin.

  • I've been looking into this problem for a bit now, and I'm pretty sure the cause is that javascript isn't waiting for the external function to finish before it executes the code that returns the value to Construct; therefore while I tell it to find out the number to return, then return the number, it actually returns the number, then figures out what number it was supposed to return.

    Now what I need to know is the solution.

  • Bump for new question.

  • aha, I think I solved it.

    What I had to do is follow the kongregate example and declare my own runtime, so

    in function() (the big one that encompasses most of runtime.js)

    declare

    var myRuntime = null;
    var myInstance = null;

    Then in pluginProto.Instance() set the values to

    myRuntime = this.runtime;
    myInstance = this;

    Then proceed to use these variables where needed.

    myRuntime.trigger(cr.plugins_.Foo.prototype.cnds.Foobar, myInstance);
  • yep, it looks like this

    Cnds.prototype.Foobar = function (myparam)
    {
         // Generic comment here
         console.log("Some Text Here");
         return true;
    };
    

    The function doesn't get called (no console log entry, no actions from returning true).

  • Now I'm having a different problem, this time it's with expressions.

    Here's my code:

    var theReturnNumber = 0;
    
    Exps.prototype.getThisNumber = function (ret)
    {
         MyExternalFunction(function(response)
         {     console.log(response);
              theReturnNumber = response;
         });
              
         ret.set_int(theReturnNumber);
    };
    

    I call this 2ce in a row in construct, essentially saying

    if(theReturnNumber == X)
         Textbox.text = theReturnNumber;
    

    except with construct's trigger/event system

    Here's what happens:

    The console log displays the correct number every time I call the expression.

    The first time I call the if/display, it returns 0 to both if it is == X and displaying in the textbox.

    Every time after the first that I call it, it returns the number it should have returned the last time I called it (the number the console log returned last time).

    Here's what I want to happen:

    The expression to return the same number as the console.log returns every time.

    1 extra question:

    Does Construct 2 support an array as a parameter? Or should I make an array by parsing a string parameter? example: "(0, 2, 1, 4)"

    The original problem is solved; problem left below:

    Hello, new developer here and I'm making a plugin to integrate an existing API with Construct 2.

    I figure the most efficant way to make a number of conditions is to make them triggered, but I can't seem to make triggered conditions work, for example, if my plugin had ID: Foo, and I was trying to trigger condition Foobar, I would try:

    this.runtime.trigger(cr.plugins_.Foo.prototype.cnds.Foobar, this);

    but this line of code appears to break when I export (HTML5, minified), and test the program online.

    Some more information:

    I'm working with a pf_singleglobal plugin

    I've tried putting this code in various places in runtime.js, including pluginProto.Type() and instanceProto.onCreate().