C
Chris Livermore
Guest
Good evening guys and girls,
Im having some issues trying to figure out how to Deactivate tiles outside of the camera View, I basically have a tiling object that draws in random tiles to the whole room (which is 20000x20000) this is basically killing the memory usage of the game So I was hoping the instance_deactivate_region would help, but it seems it is not...
maybe you guys can point where I am going wrong?
My tile creation code:
my objectController Code:
Thank you so much for your help in advance!
Im having some issues trying to figure out how to Deactivate tiles outside of the camera View, I basically have a tiling object that draws in random tiles to the whole room (which is 20000x20000) this is basically killing the memory usage of the game So I was hoping the instance_deactivate_region would help, but it seems it is not...
maybe you guys can point where I am going wrong?
My tile creation code:
Code:
// @description Create Tile Map
global.background_Layer = "Background";
global.background_Tilemap_Space = layer_tilemap_create(global.background_Layer,0,0,tsSpace,room_width,room_height);
/// @description Automatically draw background.
var tileWidth,tileHeight;
tileWidth = 64; // tile width
tileHeight = 64; // tile height
var Down, Across;
Across = room_width / tileWidth; // number of time to go accross
Down = room_height /tileHeight; // number of time to go down
for (var a =1; a < Down; a++;){ // simple for loop to go down the room
for(var i =1; i < Across; i++;){ // simple for loop to go accross the room
var ran_data = irandom_range(1,100);
tilemap_set_at_pixel(global.background_Tilemap_Space,ran_data,((tileWidth/2)+1)*i,((tileHeight/2)+1)*a)
}
}
my objectController Code:
Code:
x = camera_get_view_x(view_camera[0])+camera_get_view_width(view_camera[0])/2;
y = camera_get_view_y(view_camera[0])+camera_get_view_height(view_camera[0])/2;
var _vx = camera_get_view_x(view_camera[0]);
var _vy = camera_get_view_y(view_camera[0]);
var _vw = camera_get_view_width(view_camera[0]);
var _vh = camera_get_view_height(view_camera[0]);
instance_deactivate_region(_vx - 64, _vy - 64, _vw + 128, _vh + 128, 0,1);
instance_activate_region(_vx - 64, _vy - 64, _vw + 128, _vh + 128, 1);
Thank you so much for your help in advance!