Everyname's Forum Posts

  • 6 posts
  • Hi,

    The case I am trying to crack is the following. We are implementing a change on our website to host all content in the amazon cdn cloud. This means the url (src="c2runtime.js") of the c2runtime.js must change. Changing the url in the template is easy if it would need to point to one location. But in this case we host multiple games on our portal. And I would like to find a sollution that would prevent me from having to change the url manually each time I export.

    The src in the html template would look something like this (i'm trying to set GAMENAME dynamically):

    <script src="s3.amazonaws.com/example.example.com/gamecontent/'+ GAMENAME +'/c2runtime.js"></script>

    So far I have tried finding a way to change the script's src by making it a variable and constructing the link through

    <script type="text/javascript">

    var myURL = '//s3.amazonaws.com/example.example.com/gamecontent/'+ document.title +'/c2runtime.js';

    document.getElementById('runtimeURL').src = myURL;

    </script>

    <script id="runtimeUrl" src=""></script>

    But this gets me nowhere. It doesnt set the src.

    I also tried to set it using jQuery through the following:

    <script>

    $(document).ready(function() {

    $('script#runtimeUrl').attr('src', '//s3.amazonaws.com/example.example.com/gamecontent/'+ document.title +'/c2runtime.js');

    });

    </script>

    But the page needs c2runtime.js before this is run apparently.

    Does anyone have any tips on how I can set the reference to c2runtime.js dynamically?

    Any help is greatly appreciated. If there is information you need that i forgot to include please let me know. Thanks in advance.

  • Try Construct 3

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

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

    I've been working with the Paster plugin to create a fancy pageflip animation when I came across a bug when using spritesheeted images with Canvas2d instead of WebGL (the current project required it).

    The bug itself is very minor, but it took me some time to find the culprit! The offset of the frame in the spritesheet isn't set correctly (when using canvas2d).

    I'm too new to post links or PM you, so I'll type it out. I've added the underlined code to fix the problem.

    Runtime.js line 595

    if (sprite && sprite.spritesheeted)

    {

           this.points[0].x=x1;

           this.points[0].y=y1;

           this.points[0].u=sprite.offx;

           this.points[0].v=sprite.offy;

           this.points[1].x=x2;

           this.points[1].y=y2;

           this.points[1].u=sprite.offx + sprite.width;

           this.points[1].v=sprite.offy;

           this.points[2].x=x3;

           this.points[2].y=y3;

           this.points[2].u=sprite.offx + sprite.width;

           this.points[2].v=sprite.offy + sprite.height;

           this.points[3].x=x4;

           this.points[3].y=y4;

           this.points[3].u=sprite.offx;

           this.points[3].v=sprite.offy + sprite.height;

    }

    Hope this helps!

    EDIT: Also, thanks so much for this plugin, it's awesome!

  • I got it! I looked at how the Browser plugin worked to see what I missed.

    The sollution appears to be using the instanceProto.OnCreate to determine the scope of self. (I am still not entirely sure how this works, but I'll keep learning)

    On top of that I used an event to fire the condition to the likeness of how the Browser plugin handles these kinds of things.

    Below are the relevant functions how they are implemented now:

    instanceProto.onCreate = function()

    {

         var self = this;

         window.addEventListener("startGame", function () {

              self.runtime.trigger(cr.plugins_.SessionData.prototype.cnds.OnExternalGameStart, self);

         });

    }

    pluginProto.startGame = function()

    {

         console.log("startGame request recieved");

         var event = new CustomEvent("startGame");

         window.dispatchEvent(event);

    }

    Cnds.prototype.OnExternalGameStart = function()

    {

         console.log("Trigger called");

         return true;

    }

  • To further clarify, ideally the game is already running, just not started yet. I would like to be able to let the website tell the game to start.

  • Thanks for the reply!

    Because I want to be able to show the splash screen, which contains a gameplay animation of the game, explaining the rules.

    I would like to keep it that way if at all possible, because when I change something in the gameplay or in the graphics, the animation exlplaining the game changes with it.

  • Hi,

    I'm trying to create a plugin which enables me to start the game from a button on the website the game is hosted on, and I am a bit lost.

    The condition (OnExternalGameStart) is set up and showing in Construct2. Now I want to be able to call a function on the plugin which in turn triggers the condition.

    Im trying to do this by calling:

    pluginProto.startGame = function()

    {

         console.log("startGame request recieved");

         this.runtime.trigger(cr.plugins_.SessionData.prototype.cnds.OnExternalGameStart, this);

    }

    But when I test the function I get an error message saying:

    TypeError: Cannot call method 'trigger' of undefined

    I've tried changing the "this" to self as suggested in another post, but that didn't solve it either.

    Can anyone tell me what I am doing wrong, or point me in the right direction?

    Plugin code: [Oh I can't post links yet, PM me for a link to the plugin code]

  • 6 posts