0plus1's Recent Forum Activity

  • Ashley

    I'm using the Low Latency audio plugin and on android the music keeps playing even when the application is not on screen, I need something like what you've done for the native audio plugin of phonegap.

    Thanks

  • Is there an event to check if c2 is suspended/resumed in phoneGap?

    Thanks

  • Pode sorry but it still do not work. I ended up making one myself check here: scirra.com/forum/topic51261_post323173.html

    The way I did it is the only way, and as far as my knowledge goes you can't do it in a behaviour.

  • Ashley

    Thanks, with your help I made this plugin: scirra.com/forum/topic51261_post323173.html it now works perfectly.

  • This plugin loads an image inside a sprite at runtime (lazy loading).

    To use this, add the object to the layout, position it (currently I only support top-left hotspot), then add the action to load from url.

    If you need to lazy load an image outside construct2 this is the plugin you need (read the FAQ).

    This plugin works with every browser either mobile or desktop. If you find a bug/error please report it so I can update the plugin.

    Get the

    latest version (v0.5b)

    CHANGELOG:

    v0.5b (April, 18th 2012)

    -First public release

    ---------------------------------------------------------------FAQS

    Considering that we already have one behaviour and one plugin that does exactly the same thing as mine why should you use this one?

    Short answer: it's the only one that works.

    Technical answer:

    Loading an image at runtime it's an hack, basically something that c2 wasn't made to do, both the existing plugins do not treat it as such because they were tested only on new browsers. Both of those plugins DO NOT work on android and iOS (on 4.x they make c2 crash, on 5.x they are unpredictable) and have glitches when ran inside webGL.

    Why you may ask? With the help of Ashley in this thread and with days of testing I found out that on older (or slower) browsers, the image at one point as a value that could be less than zero, null/false and even unpredictable values, this means that when ctx.drawImage gets called all sort of error happens, errors that can result in a complete crash or glitches. My plugin checks if the image has been REALLY loaded and ONLY then it draws it, as far as my knowledge goes this can be done only in a plugin because you have complete control of the drawing part.

  • Ashley The url point to an image. On device to emotions/xyz.png (xyz is the image name that changes everytime) for testing is set to http://u.dropbox.com.../emotions/xyz.png. The images works, this is an error specific to androdid 2.2 and ios4.x on "moderner" browsers it works without problem. I discovered that after .src the content of:

    this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.width (and height) are both 0. While before .src where equal to this.inst.width/height. I thought that was the problem, but even if I set:

    this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.width = this.inst.width;

    (same for height) the error still happens (and the value is set after cheching with console.log). Tomorrow I'll try your solution.

    But I think that what happens is that after .src the .width/height goes to 0 and the engine picks that for the tick it takes to set the correct value (as it's async).

  • Pode, there is an issue with your pluging, read here apparently the injected sprite is missing width and height?

    If you can help me fix this error I'm more than willing to pay you for your work.

  • It's very strange, the plugin is a behaviour that is doing this:

    this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.src = '';

              this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.src = base64string;

              this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.onload = (function (self) {

                  ?return function(info) {

                        cr.runtime.redraw = true;

                  ?};

              })(this);

    where base64string is the url of the image. The line that throws this error is just this one: this.inst.cur_animation.frames[this.inst.cur_frame].texture_img.src = base64string; even deleting all the rest it still throws that error.

    All the browser do not, only android 2.2 and iOS 4.X

    It seems strange, but maybe you have an idea about the reason this might happen and how to mitigate it, is there any other way except .src to load an image inside a sprite?

    Thanks

    Edit: Ashley sorry to bother you about this but you are the only one that can point me in the right direction

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley thanks for your help. But something else is wrong here. I wrapped your code to check:

    if(this.height>0&&this.width>0){

                        ctx.drawImage(cur_image,

                                   myx,

                                   myy,

                                   this.width,

                                   this.height);

                   }

    And it throws the same error here: this.height.

    Why do you think this is happening?

  • Maybe it's not the right direction, but probably Ashley knows what we are talking about.

    On iOS4 (not 5)and Android too, this plugin (inject)make the entire canvas hang completely. Xcode do not show anything (because it do not have a js debugger) instead LogCat in Eclipse fires this:

    INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value.

    The incriminating line is this one: ctx.drawImage(cur_image, myx, myy, this.width, this.height);

    Any idea why and how to fix it?

  • Thanks, if you point me in the right direction maybe I can do it myself otherwise let me know when you are ready, it's the last piece missing from my application.

  • I love you.

    Disregard what I said and please sticky his solutions because it's a life saver!

0plus1's avatar

0plus1

Member since 29 Dec, 2010

None one is following 0plus1 yet!

Connect with 0plus1

Trophy Case

  • 13-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies