Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:events:js-code [2019/06/13 21:27]
piyushpalawat99
gdevelop5:events:js-code [2020/01/21 00:52] (current)
bouh
Line 36: Line 36:
 ## Documentation 📚 ## Documentation 📚
  
-  * Read **[the game engine documentation](http://4ian.github.io/​GD-Documentation/​GDJS%20Runtime%20Documentation/​)** to get started. ​+  * Read **[the game engine documentation](https://docs.gdevelop-app.com/​GDJS%20Runtime%20Documentation/​)** to get started. ​
   * You can also browse directly the **[GDJS game engine source code](https://​github.com/​4ian/​GD/​tree/​master/​GDJS/​Runtime)**.   * You can also browse directly the **[GDJS game engine source code](https://​github.com/​4ian/​GD/​tree/​master/​GDJS/​Runtime)**.
  
Line 54: Line 54:
 </​code>​ </​code>​
  
-See the documentation of [[http://4ian.github.io/​GD-Documentation/​GDJS%20Runtime%20Documentation/classes/​gdjs.Variable.html|gdjs.Variable]] and [[http://4ian.github.io/​GD-Documentation/​GDJS%20Runtime%20Documentation/classes/​gdjs.VariablesContainer.html|gdjs.VariablesContainer]].+See the documentation of [[https://docs.gdevelop-app.com/​GDJS%20Runtime%20Documentation/​gdjs.Variable.html|gdjs.Variable]] and [[https://docs.gdevelop-app.com/​GDJS%20Runtime%20Documentation/​gdjs.VariablesContainer.html|gdjs.VariablesContainer]].
  
 ### Move object at the position of another, check if the game is rendering the first frame ### Move object at the position of another, check if the game is rendering the first frame
Line 61: Line 61:
 const players = runtimeScene.getObjects("​Player"​);​ const players = runtimeScene.getObjects("​Player"​);​
 const playerHitBoxes = runtimeScene.getObjects("​PlayerHitBox"​);​ const playerHitBoxes = runtimeScene.getObjects("​PlayerHitBox"​);​
 +//Check if one instance of objects exist, here if scene haven'​t one
 +//of the two object on scene we avoid to compute rest of code.
 if (playerHitBoxes.length === 0 || players.length === 0) return; if (playerHitBoxes.length === 0 || players.length === 0) return;
  
 +//At the first frame
 if (runtimeScene.getTimeManager().isFirstFrame()) { if (runtimeScene.getTimeManager().isFirstFrame()) {
 +//Hide the first instance of playerHitBoxes
   playerHitBoxes[0].hide();​   playerHitBoxes[0].hide();​
 } }
  
 +//Set the positions
 players[0].setX(playerHitBoxes[0].getX() - 12); players[0].setX(playerHitBoxes[0].getX() - 12);
 players[0].setY(playerHitBoxes[0].getY());​ players[0].setY(playerHitBoxes[0].getY());​