|
@@ -7,7 +7,7 @@
|
|
|
ifdef::env-github,env-browser[:outfilesuffix: .adoc]
|
|
|
|
|
|
|
|
|
-To add blocks to the framework, you just have to add them to the BlockManager - This happens by specifying a block object (has to extend *cubes.Block*, by overriding methods you can specify own behaviours). Each block needs at least one “skin, which you have to pass in the constructor of the *cubes.Block* class). A “skin contains all information to display the block - Texture-Index in the Atlas, Transparency and so on.
|
|
|
+To add blocks to the framework, you just have to add them to the BlockManager - This happens by specifying a block object (has to extend *cubes.Block*, by overriding methods you can specify own behaviours). Each block needs at least one "`skin`", which you have to pass in the constructor of the *cubes.Block* class). A "`skin`" contains all information to display the block - Texture-Index in the Atlas, Transparency and so on.
|
|
|
|
|
|
After initialising your object, you have to register it in the BlockManager:
|
|
|
|
|
@@ -28,8 +28,8 @@ You can register them by calling `CubesTestAssets.registerBlocks();`.
|
|
|
|
|
|
== Single Texture Block
|
|
|
|
|
|
-
|
|
|
-image::http://destroflyer.mania-community.de/other/imagehost/cubes/block_stone.png[block_stone.png,width="150",height="",align="right"]
|
|
|
+[.right.text-left]
|
|
|
+image::http://destroflyer.mania-community.de/other/imagehost/cubes/block_stone.png[block_stone.png,width="150",height=""]
|
|
|
|
|
|
Let's say, you want to add a simple block, which uses the same texture on every face. The framework recognizes, when only one texture is specified and therefore uses this for each face:
|
|
|
|
|
@@ -43,8 +43,8 @@ BlockManager.register(blockStone);
|
|
|
|
|
|
== Face-Dependant Textures Block
|
|
|
|
|
|
-
|
|
|
-image::http://destroflyer.mania-community.de/other/imagehost/cubes/block_wood.png[block_wood.png,width="150",height="",align="right"]
|
|
|
+[.right.text-left]
|
|
|
+image::http://destroflyer.mania-community.de/other/imagehost/cubes/block_wood.png[block_wood.png,width="150",height=""]
|
|
|
|
|
|
Now it's time to get prettier blocks - The wood block as known in Minecraft has two textures: Top/Bottom (cross-section) and Left/Right/Front/Back (bark). A simple way to set the texture for each face is to just give 6 textures to the skin (in the right order :P):
|
|
|
|
|
@@ -66,8 +66,8 @@ BlockManager.register(blockWood);
|
|
|
|
|
|
Last but not least: What if a block wants to change its texture according to its environment?
|
|
|
|
|
|
-
|
|
|
-image::http://destroflyer.mania-community.de/other/imagehost/cubes/block_grass.png[block_grass.png,width="150",height="",align="right"]
|
|
|
+[.right.text-right]
|
|
|
+image::http://destroflyer.mania-community.de/other/imagehost/cubes/block_grass.png[block_grass.png,width="150",height=""]
|
|
|
|
|
|
A nice example would be a grass block - If it's on the surface, it contains a nice grass texture at the top face and a little earth-grass-transition at the sides. Otherwise, all 6 sides should display an earth texture.
|
|
|
Special behaviours like this can be achieved by overwriting the *getSkinIndex* method:
|