Simple protection of published game. Part Two.

4
  • 38 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

the-sitelock.capx

Download now 177.78 KB

Stats

8,227 visits, 18,698 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Prepare your events

In previous tutorial we used a bunch of local text variables to mask our real web page address the game is hosted on. And it works quite well!

But that security check system could be very problematic if you suddenly decide to host your game in multiple places.

This time we will use very different approach to this problem. We will use less events and at the same time we will make our system a lot better!

Add a new System: On start of layout condition. Inside that condition create a new Local text variable tmp. You can leave it empty.

Now add a new empty event with System: Set tmp to Browser.Domain

Here we are simply setting a tmp local text variable to current domain name.

If you do not know what domain name is you can learn some more over here Domain name (wikipedia).

In short. If your game url is for example:

http://www.scirra.com/arcade/addicting-rotary-games/848/airscape

then domain name for this page will be only a string:

scirra.com

(Bare in mind that empty event works exactly the same like Every tick event. But placing it as a sub-event of On start of layout will make it run only once.)

Next we need to do something to test if tmp = Browser.Domain is equal to our page where game is hosted. This is very simple.

Add another sub-event *System: Compare two values" and set it like this

First value is tmp variable.

Second value is a string that contains a name of your domain where your game is uploaded.

Now we only need to add an action for that compare. Let's make it so if

First value = Second value -> SpriteFont: Set text to "Welcome player"

And if comparison is not equal we will use simple

Else -> SpriteFont: Set text to "I think you have lost my friend".

This is how it all works.

On start of the layout we are setting a variable tmp to current domain name.

If variable tmp is equal to "scirra.com" then we display welcoming message on the screen.

if domain name is not equal to "scirra.com" then we display different message.

Now let's make it work with multiple domains.

  • 2 Comments

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