Hi,
I'm working on a multiplayer card game, basically a Hearthstone clone, so I can get my head around the general construct to build something more complex later.
Being completely new to Construct, and game design in general, I built the game with a very simple AI first, and I'm now going back and adding in multiplayer (and realising that was a perhaps not the best idea) but I'm falling down at a very early hurdle.
I've built a card select screen, which you land on after logging in. on this screen, I need to create a variable amount on instances of my Deck object, which displays the cards, set several variables to each, being pulled from an array based on the animation frame of each card, and arrange them on the screen to be selected (there is more to do after that, but it's this early I'm falling down.
The host creates the objects by looping through the array with the stats and creating an object for each entry, I then have a series of actions set to run on every tick that rearranges the cards based on a formula using the loopindex and ordering by animation frame. This all works perfectly on the host machine, but I am not getting the right result on the peer.
I have it set up as such:
On start of layout > sync Deck and necessary variables
Signalling server login stuff
On Signalling joined room > AJAX: request Cards.json
On "Cards" Complete > array: load from ajax.last data
create cards, etc
I know everything up to here is working as it is working on the host. Then:
On peer connect > function to broadcast message with cards array as .json
On message received > array:load from message & send message back that array has loaded
On message received > broadcast message back to peer
On message received > events to assign animation frame to cards on peer machine
It seems to be on this last step that it falls down. I've added some bits of text to try to help me debug and I've discovered a few things that are puzzling to me. Firstly, on the peer machine the count of instances of the cards shows 1 more than on the host (I didn't think that could happen with the object synced?), next, as part of the reaction to the last message the peer receives, I added a for each loop on the card object and told it to append a text field with what should be the animation frame (stored as a variable, synced from the host) of each card, and despite my count saying there were 22 instances, the loop only returned two figures?
I am very confused??
Here's my files (although apologies in advance for the mess, as I said I'm learning as I go, and trying to retro fit multiplayer to something I'd already built)
Everything I've described above is on event sheets PS-DeckBuilder, PS-Outgoing, & PS-Incoming
https://drive.google.com/open?id=1N3aNkzdxVEp8sbw3bFCHMjrgDQ_Gkyof