How to build a Multiplayer Game with Photon

  • 25 favourites

Attached Files

The following files have been attached to this tutorial:

.capx

multipphotontutorial.capx

Download now 174.34 KB

Stats

9,290 visits, 17,502 views

Tools

This simple tutorial will teach you how to create a simple platformer game & a simple chat with Photon in only 12 events.

The plugin is available here : scirra.com/forum/plugin-photon-cloud_t125222

Photon Setup

First of all you need a Photon Real time cloud service on

PhotonEngine.com

Make a account and take the free plan for this tutorial.

After that copy the App ID who is there on your page :

And Prepare your Construct 2.

Make a blank project and insert the Photon Plugin.

After that past your App-ID here:

This is all for the Setup of the Photon Plugin.

Connexion

Do a thing like:

On start of the layout connect to the server and when the player is connected to the server make it join a room or create a room automatically Like this :

Create Player on each screen

The tutorial really start here. :p

This is the time to say to the game than when someone join the room the game will create a character for the player.

First create a sprite with a variable named ActorNr.

And now we will use the raise event for the first time.

*

The code is the number of the event.

Data is if you want to send something with the event.

the Cache save the event for later when someone will join the game the event will be automatically reexecuted for this player at the start of the layout.

Receiver is who will received the event.

*

The other thing are not important for this tutorial.

And finally we associate the Photon Player ID and the character of the player to be able to select them later.

Finally all of this will be a thing like this:

Send your Position to every player

I made a small mistake here , replace each int by float

The movement behaviour are enabled only for the player object who have your ID.

And your X & Y are send to other players.

Add this line to destroy the sprite of the players who left the game

Simple Chat

For the chat add these objects:

TextBox named chatlog : To show what the people say.

Textbox named msgbox : To write what you want to say.

Button named sendbutton: To send your message.

And do this simple thing:

Conclusion

This is all you need to know to make a multiplayer platformer game & a chat with Photon.

If something don't work the capx is attached to this tutorial.

:D

.CAPX

multipphotontutorial.capx

Download now 174.34 KB
  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!