valerypopoff, do you think there is a way to say for example, create a class on the *.js side and then make every instance of a sprite have an instance of that class ?
Think of it as polymorphism, your "extends" so to speak.
I don't think that you actually meant polymorphism. Polymorphism means something else.
I don't know what you mean by "make instance of a sprite HAVE an instance of js class". You certainly can if you just imagine that this is the case. Create two instances of a sprite. Create two instances of a js class. Done. They HAVE each other. Do whatever you want with them.
I'd recommend you to think of a game object (not a class) as of a collection of two things:
— a model that actually stores data, has methods that operate on its data, and virtually represents a game object
— a view that visually represents a game object for a person who's looking at the screen
If you're using javascript and classes and objects, a model is a js-object. A view is a sprite or a collection of sprites.
If you have a good architecture, a game object has only one model and one view. When the model changes, the view should be updated (or update itself). In this sense, a view and a model should be somehow virtually connected so the view could update itself according to a certain model. A view should somehow address the model to get its data.
If we're talking about game objects that have only one instance in the game, like Player, you just make the Player's view address the Player's model by remembering that the model is stored in the variable named "player". And that's it. There's no point of storing this name anywhere on the Construct side, because you'll eventually have to do JS.Call "player.update" and it's easier than doing JS.Call PlayerSprite.object_variable_name & ".update".
But if we're talking about game objects that exist in plural, like enemies, then you're probably creating the js-objects and sprite instances dynamically. Then it makes sense to store js-objects in the array or something and then give every sprite the instance variable, like, "index" and set it to it's js-object's index in the array so you can later do:
Enemy - on collision with - Bullet: JS.Call "Enemies_arr[" & Enemy.index & "].get_hit"
Ooooor if you have to do this often and you came up with the handy js-wrapper:
Enemy - on collision with - Bullet: JS.Call "EnemyManager.get_hit"(Enemy.index)
If you're really interested in creating an elegant architecture using javascript, read this: en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
And for the love of god read the manual: readymag.com/valerypopoff/valerypopoff-js-plugin I specifically illustrated there the very thing that you're asking about.