---
title: 'Scene_Constructor'
disqus: hackmd
tags: 'API'
---
## **Constructor**
## **CloudScene**
***• CloudScene(CloudGame game, string sguid)***
| parameter | note |
|:----- |:--------------------------------- |
| game | the CloudGame object that is successfully created and set online|
| sguid | the scene’s SGUID |
If the sguid is a static scene, call Launch() directly into the scene. If the sguid is an active scene, there are three approaches as listed:
1. Call `Launch()` to build a new replica of the scene and enter that scene.
2. Call `Match()` and enter a scene replica that is already created according to the server’s matching. The scene replicas that are built first will be prioritized when matching. The matching will not move on to the next scene before the number of players reaches the maximum capacity in the previous one. Please be aware that if there is no limit on the number of players in a scene, the Cloud server will automatically change to `FairMatch()` to do the matching.
3. Call `FairMatch()` and match every player to a scene that is already built one by one accordingly. This method allows a fair distribution of players in every scene replica.
Whether the player enters the scene successfully or not, the OnCompletion() event will be triggered. Here is the note for the code that is sent back:
| status code| note |
|:------ |:---------------------- |
| 0 | enter the scene successfully |
| not 0 | fail to enter the scene, and the code is the error code |
If no player is waiting for matching currently, the error code will be sent back as 22. If it happens, a CloudScene has to be rebuilt. Also, use `Launch()` to build a new scene instance at the same time and wait for someone to match with it.
***• CloudScene(CloudGame game, string sguid, uint sid)***
Used in an active scene, when a built scene replica is known. Use this Constructor to create a scene item and call `Launch()` to enter that scene replica.
| parameter | note |
|:----- |:--------------------------------- |
| game | the CloudGame object that is successfully created and set online|
| sguid | the scene’s SGUID |
| sid | the scene’s SID |
***• CloudScene(CloudGame game, string sguid, bool isLocked)***
Used in creating an active scene replica, but after that only `Launch()` can be called.
| parameter | note |
|:-------- |:--------------------------------------------- |
| game | the CloudGame object that is successfully created and set online |
| sguid | the scene’s SGUID |
| isLocked | true: this scene does not accept the server's automatic pairing / false: the function is the same as the first Constructor|