Thanks for your answers, it solved my problem.
My final code is:
I'll check later how i want this item to interact with ennemies and other entites but for the moment, it's usable as it is.
My final code is:
Code Select
rateau:add_collision_test("overlapping", function(rateau, entity)
if( entity:get_sprite()~=nil) then
local nom_sprite = entity:get_sprite():get_animation()
if(nom_sprite == "on_ground")then
local coords_x, coords_y, coords_layer = entity:get_position()
local brush_explosed = map:create_custom_entity{
x = coords_x,
y = coords_y,
layer = layer,
width = 8,
height = 8,
direction = 0,
}
-- on affiche l'animation de destruction
local brush_sprite= brush_explosed:create_sprite("entities/bush_green")
brush_sprite:set_animation("destroy")
-- on remove le sprite du brush
entity:remove()
end
end
I'll check later how i want this item to interact with ennemies and other entites but for the moment, it's usable as it is.