Bonsoir j'ai débuter il y a peu de temp j'ai suivie tout les tutos video =)
j'ai beau chercher chercher j'ai essayer pas mal de chose mais rien a faire mon image ne veux pas s'animer comme elle devrais le faire
si quelqu'un pourrais m'aider est me dire le pourquoi du comment faire pour que j'apprend de mes erreur merci d'avance a vous.
Image et Gif en liens:
Sprite animer:
https://gyazo.com/18cbdc9ad0a456cfe7ee7c275ac9b58b
Resulta en jeux:
https://gyazo.com/37ae15963870be4d140a8daa614aa976
Script de la maps:
Quotelocal map = ...
local game = map:get_game()
map.overlay_angles = {
7 * math.pi / 4
}
map.overlay_step = 1
function map:set_overlay()
map.overlay = sol.surface.create("fogs/Pluie_anime.png")
map.overlay:set_opacity(96)
map.overlay_m = sol.movement.create("straight")
map.restart_overlay_movement()
end
function map:restart_overlay_movement()
map.overlay_m:set_speed(16)
map.overlay_m:set_max_distance(100)
map.overlay_m:set_angle(map.overlay_angles[map.overlay_step])
map.overlay_step = map.overlay_step + 1
if map.overlay_step > #map.overlay_angles then
map.overlay_step = 1
end
map.overlay_m:start(map.overlay, function()
map:restart_overlay_movement()
end)
end
function map:on_started(destination)
map:set_overlay()
end
function map:on_draw(destination_surface)
-- Make the overlay scroll with the camera, but slightly faster to make
-- a depth effect.
local camera_x, camera_y = self:get_camera_position()
local overlay_width, overlay_height = map.overlay:get_size()
local screen_width, screen_height = destination_surface:get_size()
local x, y = camera_x, camera_y
x, y = -math.floor(x), -math.floor(y)
-- The overlay's image may be shorter than the screen, so we repeat its
-- pattern. Furthermore, it also has a movement so let's make sure it
-- will always fill the whole screen.
x = x % overlay_width - 16 * overlay_width --2
y = y % overlay_height - 16 * overlay_height
local dst_y = y
while dst_y < screen_height + overlay_height do
local dst_x = x
while dst_x < screen_width + overlay_width do
-- Repeat the overlay's pattern.
map.overlay:draw(destination_surface, dst_x, dst_y)
dst_x = dst_x + overlay_width
end
dst_y = dst_y + overlay_height
end
end
-- Event called after the opening transition effect of the map,
-- that is, when the player takes control of the hero.
function map:on_opening_transition_finished()
end
Tu crées une surface et non un sprite, la surface = ton image entière, le sprite = l'animation
tu dois remplacer
map.overlay = sol.surface.create("fogs/Pluie_anime.png")
par
map.overlay = sol.sprite.create("fogs/Pluie_anime") -- le nom du .dat sans l'extention
le script que tu utilises est un script pour fogs, qui scrollent en temps normal.
local map = ...
local game = map:get_game()
function map:set_overlay()
map.overlay = sol.sprite.create("fogs/Pluie_anime")
map.overlay:set_opacity(96)
end
function map:on_started(destination)
map:set_overlay()
end
function map:on_draw(destination_surface)
-- Make the overlay scroll with the camera, but slightly faster to make
-- a depth effect.
local camera_x, camera_y = self:get_camera_position()
local overlay_width, overlay_height = map.overlay:get_size()
local screen_width, screen_height = destination_surface:get_size()
local x, y = camera_x, camera_y
x, y = -math.floor(x), -math.floor(y)
-- The overlay's image may be shorter than the screen, so we repeat its
-- pattern. Furthermore, it also has a movement so let's make sure it
-- will always fill the whole screen.
x = x % overlay_width - 16 * overlay_width --2
y = y % overlay_height - 16 * overlay_height
local dst_y = y
while dst_y < screen_height + overlay_height do
local dst_x = x
while dst_x < screen_width + overlay_width do
-- Repeat the overlay's pattern.
map.overlay:draw(destination_surface, dst_x, dst_y)
dst_x = dst_x + overlay_width
end
dst_y = dst_y + overlay_height
end
end
-- Event called after the opening transition effect of the map,
-- that is, when the player takes control of the hero.
function map:on_opening_transition_finished()
end
Merci pour ton aide alors l'animation fonctionne mais pas l'opacity
Error: In on_started: [string "maps/houses/campagne.lua"]:6: attempt to call method 'set_opacity' (a nil value)
Résulta IG: je réglerez le soucis d'animation
https://gyazo.com/0b337b0720215822203eac9758bea060
Quote from: Delltus on March 10, 2017, 03:52:03 PM
Merci pour ton aide alors l'animation fonctionne mais pas l'opacity
Error: In on_started: [string "maps/houses/campagne.lua"]:6: attempt to call method 'set_opacity' (a nil value)
Résulta IG: je réglerez le soucis d'animation
https://gyazo.com/0b337b0720215822203eac9758bea060
Le soucis c'est que le moteur ne gère toujours pas l'opacité sur les sprites, que sur les surfaces.
il existe un moyen "trompe l'oeil" en utilisant surface.
local map = ...
local game = map:get_game()
local total_frame = 100 -- tu peux modifier ca, c'est le nombre de frame a attendre avant que la pluie ne change de sprite
local current_frame = 0
local frame = 0
function map:set_overlay()
map.overlay = sol.sprite.create("fogs/Pluie_anime")
map.overlay:set_opacity(96)
end
function map:on_started(destination)
map:set_overlay()
end
function map:on_draw(destination_surface)
-- Update the rain frame
current_frame = current_frame + 1
if current_frame == total_frame then
current_frame = 0
frame = (frame + 1) % 3
end
-- Make the overlay scroll with the camera, but slightly faster to make
-- a depth effect.
local camera_x, camera_y = self:get_camera_position()
local overlay_width, overlay_height = map.overlay:get_size()
local screen_width, screen_height = destination_surface:get_size()
local x, y = camera_x, camera_y
x, y = -math.floor(x), -math.floor(y)
-- The overlay's image may be shorter than the screen, so we repeat its
-- pattern. Furthermore, it also has a movement so let's make sure it
-- will always fill the whole screen.
x = x % overlay_width - 16 * overlay_width --2
y = y % overlay_height - 16 * overlay_height
local dst_y = y
while dst_y < screen_height + overlay_height do
local dst_x = x
while dst_x < screen_width + overlay_width do
-- Repeat the overlay's pattern.
map.overlay:draw_region(0, 320 * frame, 320, 240, destination_surface, dst_x, dst_y)
dst_x = dst_x + overlay_width
end
dst_y = dst_y + overlay_height
end
end
Pas tester mais ca devrait marcher, tu pourras utiliser set_opacity car on utilise une surface
La meilleure solution est d'attendre que Solarus permet le set_opacity pour les sprites
Merci pour ton aide, j'ai modifier mon image pour la rendre transparente sa seras plus simple ^^