Call a function of a Sprite instance from a custom plugin

For developers using the Construct 2 Javascript SDK

Post » Mon May 05, 2014 1:08 pm

I'm passing a Sprite instance to a custom plugin I'm making, when passed I try to change its frame. I also tried changing its frame a few seconds later and got the same results.

Here's the function I'm passing the Sprite to in my custom plugin.

Code: Select all
Acts.prototype.SetSprite = function (sprite)
{
      if (!sprite) return;
     
      cr.plugins_.Sprite.prototype.acts.SetAnimFrame.call(sprite, 2);
};


Here's the error:

Code: Select all
Uncaught TypeError: undefined is not a function

http://localhost:50000/Sprite_plugin.js, line 1529 (col 9)


The function itself is called successfully, but the error seems to refer to a function call in Sprite/SetAnimFrame.

Any idea what's going on?
B
5
S
1
Posts: 28
Reputation: 431

Post » Sat Jun 07, 2014 1:32 am

Just a wild guess...Have you tried using -

cr.plugins_.Sprite.prototype.acts.animation.SetAnimFrame.call(sprite, 2); ?
For game development / IT services contact - [email protected]

List of published iOS apps -
https://itunes.apple.com/us/artist/ravi ... d693234511
B
84
S
20
G
3
Posts: 337
Reputation: 7,368

Post » Sun Jun 08, 2014 4:44 pm

@kmsravindra

The runtime.js of sprite plugin, has no function named
Code: Select all
cr.plugins_.Sprite.prototype.acts.animation.SetAnimFrame
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests