M
mpolder
Guest
I've been trying to make a platformer with an object that I use as a solid wall for any solid objects. Instead of making the whole stage it'd be easier to replace all the tiles on the tilemap with the solid automatically so i dont have to update it all the time. I've made some progress (i think) but got stuck. Does anyone know what is going wrong?
Just a bit of clarification, this code is meant to loop through all the layers and find the ones starting with "S_" (meaning they're solid) and place objects on every single tile that the layer contains. Right now all it does is find the layer and fill the entire stage with the object since I didnt find a way to actually see if the cell on the tilemap was "occupied".
I appreciate any help
Just a bit of clarification, this code is meant to loop through all the layers and find the ones starting with "S_" (meaning they're solid) and place objects on every single tile that the layer contains. Right now all it does is find the layer and fill the entire stage with the object since I didnt find a way to actually see if the cell on the tilemap was "occupied".
Code:
///Spawn solidblocks
var l = layer_get_all();
for (var i = 0; i < array_length_1d(l); i++;) {
var lName = layer_get_name(l[i]);
if(string_pos("S_", lName) == 1) {
for (var xx = 0; xx<=tilemap_get_width(l[i]);xx+=1) {
for (var yy = 0; yy<=tilemap_get_height(l[i]);yy+=1) {
var ted = tilemap_get(l[i], xx, yy);
var obj = instance_create_layer(xx*32, yy*32, 1, obj_solid);
//show_message(string(xx) + "-" + string(yy));
with(obj) {
image_xscale = tilemap_get_tile_width(ted) / sprite_get_width(spr_solid);
image_yscale = tilemap_get_tile_height(ted) / sprite_get_height(spr_solid);
}
}
}
}
}