cocos.grid module¶
Grid data structure
-
class
Grid3D
¶ Bases:
cocos.grid.GridBase
Grid3D is a 3D grid implementation. Each vertex has 3 dimensions: x,y,z
The indexed vertex array will be built with:
self.vertex_list.vertices: x,y,z (floats) self.vertex_list.tex_coords: x,y,z (floats) self.vertex_list.colors: RGBA, with values from 0 - 255
-
get_original_vertex
(x, y)¶ Get the original vertex coordinate. The original vertices are the ones weren’t modified by the current action.
- Parameters
- xint
x-vertex
- yint
y-vertex
- Return type
(float, float, float)
-
get_vertex
(x, y)¶ Get the current vertex coordinate
- Parameters
- xint
x-vertex
- yint
y-vertex
- Return type
(float, float, float)
-
set_vertex
(x, y, v)¶ Set a vertex point is a certain value
- Parameters
- xint
x-vertex
- yint
y-vertex
- v(float, float, float)
tuple value for the vertex
-
-
class
GridBase
¶ Bases:
object
A Scene that takes two scenes and makes a transition between them
-
after_draw
(camera)¶ Called by CocosNode when the texture is already grabbed. The FrameBuffer will be unbound and the texture will be drawn
- Parameters
- cameraCamera
The target’s camera object.
-
before_draw
()¶ Binds the framebuffer to a texture and set a 2d projection before binding to prevent calculating a new texture
-
init
(grid)¶ Initializes the grid creating both a vertex_list for an independent-tiled grid and creating also a vertex_list_indexed for a “united” (non independent tile) grid.
- Parameters
- grideuclid.Point2
size of a 2D grid
-
property
active
¶ Determines whether the grid is active or not :type: bool
-
texture
= None¶
-
-
class
TiledGrid3D
¶ Bases:
cocos.grid.GridBase
TiledGrid3D is a 3D grid implementation. It differs from Grid3D in that the tiles can be separated from the grid.
The vertex array will be built with:
self.vertex_list.vertices: x,y,z (floats) self.vertex_list.tex_coords: x,y (floats) self.vertex_list.colors: RGBA, with values from 0 - 255
-
get_original_tile
(x, y)¶ Get the 4-original tile coordinates.
Coordinates positions:
3 <-- 2 ^ | 0 --> 1
- Parameters
- xint
x coordinate of the tile
- yint
y coordinate of the tile
- Return type
[ float, float, float, float, float, float, float, float, float, float, float, float ]
- Returns
The 4 coordinates with the following order: x0, y0, z0, x1, y1, z1,…,x3, y3, z3
-
get_tile
(x, y)¶ Get the current tile coordinates.
Coordinates positions:
3 <-- 2 ^ | 0 --> 1
- Parameters
- xint
x coordinate of the tile
- yint
y coordinate of the tile
- Return type
[ float, float, float, float, float, float, float, float, float, float, float, float ]
- Returns
The 4 coordinates with the following order: x0, y0, z0, x1, y1, z1,…,x3, y3, z3
-
set_tile
(x, y, coords)¶ Set the 4 tile coordinates
Coordinates positions:
3 <-- 2 ^ | 0 --> 1
- Parameters
- xint
x coodinate of the tile
- yint
y coordinate of the tile
- coords[ float, float, float, float, float, float, float, float, float, float, float, float ]
The 4 coordinates in the format (x0, y0, z0, x1, y1, z1,…, x3, y3, z3)
-