Multiplayer dynamic character texture and infos

Post your help queries and engine programming questions here

Multiplayer dynamic character texture and infos

Postby Laurent » Wed Jan 07, 2015 11:29 am

Hi,

I bought the personnal licence in order to developp an isometric multiplayer tchat for one of my websites.
My problem is that each character has it own texture, and that texture should be dynamically loaded.

I start from the example 24.5.

I tried sending arguments(characterTextureImage) with entitycreate :
Code: Select all
// client.js file
// Ask the server to create an entity for us
ige.network.send('playerEntity',characterTextureImage);


It works fine on serverside and I can get my characterTextureImage argument in the init method of characterContainer and Character.

But on the client side, when trying to apply the texture for other characters, I can't find the characterTextureImage.
Code: Select all
// CharacterContainer.js
if (!ige.isServer) {
         ../..
   
         // Create a character entity as a child of this container
         self.character = new Character()
            .../..
      }


Thanks for your help ;)
Last edited by Laurent on Sat Jan 10, 2015 7:15 pm, edited 1 time in total.
User avatar
Laurent
 
Posts: 6
Joined: Wed Jan 07, 2015 10:15 am

Re: Multiplayer dynamic character texture

Postby TheBenji » Wed Jan 07, 2015 8:14 pm

You'd probably need to send the filename/path from the image to the client and then the client needs to load the texture on it's own from this path and you can apply it as usual.

I could be wrong though...
TheBenji
 
Posts: 7
Joined: Sat Nov 22, 2014 8:42 pm

Re: Multiplayer dynamic character texture

Postby Laurent » Wed Jan 07, 2015 10:04 pm

I agree with you, but I can't fidn the way to send the image path from the server to the client :cry:
User avatar
Laurent
 
Posts: 6
Joined: Wed Jan 07, 2015 10:15 am

Re: Multiplayer dynamic character texture and infos

Postby Laurent » Sat Jan 10, 2015 7:17 pm

I just need to send parameters (as texture url, playername, playerscode) to display them on every player screen...
Help please :|
User avatar
Laurent
 
Posts: 6
Joined: Wed Jan 07, 2015 10:15 am

Re: Multiplayer dynamic character texture and infos

Postby robaldred » Tue Feb 17, 2015 9:36 pm

Hey Laurent, sorry for the delay. I wanted to reply here instead of via private message so others can benefit from the discussion.
What you're asking is quite simple if you know how :)

What you need to do is pass around instantiation variables. You do this by defining the streamCreateData method on your entity this method must return your instantiation object.

This can be seen in action in example 24.1-network-stream, the speed of the rotators is passed over the network to all the clients.
Let me illustrate with little snippet.

Character.js
Code: Select all
var Character = IgeEntity.extend({
    init: function (texturename) {
        this._texturename = texturename;

        var self = this;
   
        if(ige.isClient) {
            this._tex = new IgeTexture('assets/textures/sprites/' + this._texturename);
            this._tex.on('loaded', function () {
                self.texture(self._tex);
            });
           
        }
       
    },

    streamCreateData: function() {
        return this._texturename;
    }
});



On your server you'd create a character by calling:
Code: Select all
char = new Character('texture.png')
    .streamMode(1)
    .mount(this.mainScene);


This it, the stream will take care of creating your Character entities on the clients and passing the texture to it.
The down side is the streamCreateData can only handle strings when using NetIO, so if you wanted to send more than one property you'd need to send it say as a comma separated string and then re-assemble it in your init method.

Something like:

Code: Select all
//server
new Character('texture.png,playername,playercode');

//character.js
init: function(args) {
   this._args = args.split(',');
   this._texturename = this._args[0];
   this._playername = this._args[1];
   this._playercode = this._args[2];

   //.... other init stuff
},
streamCreateData: function() {
   return this._texturename + ',' + this._playername + ',' + this._playercode;
}


I hope this gives you what you need, let me know how you get on.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: Multiplayer dynamic character texture and infos

Postby Laurent » Mon Mar 09, 2015 3:10 pm

Thanks a lot Rob,

It works fine :)
User avatar
Laurent
 
Posts: 6
Joined: Wed Jan 07, 2015 10:15 am

Re: Multiplayer dynamic character texture and infos

Postby robaldred » Mon Mar 09, 2015 3:15 pm

Excellent, looking forward to see what you've been building.
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England


Return to Help & Questions

Who is online

Users browsing this forum: Google [Bot] and 1 guest