the good thing is that I use a custom entitie to launch the menu exactly like you said. The bad thing is that the scripts of pause menu are very complex and I don't find any help in them.
Thanks anyway.
Thanks anyway.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Diarandor on November 16, 2017, 12:21:29 PM
You don't need to code a menu for each door. You can pass all the necessary info from the door to the menu with an initialization function.
-- Lua script of enemy mon_enemie.
-- This script is executed every time an enemy with this model is created.
-- Feel free to modify the code below.
-- You can add more events and remove the ones you don't need.
-- See the Solarus Lua API documentation for the full specification
-- of types, events and methods:
-- http://www.solarus-games.org/doc/latest
local enemy = ...
local game = enemy:get_game()
local map = enemy:get_map()
local hero = map:get_hero()
-- sprite du corps de l'enemie
local body_sprite
-- sprite de l'épée de l'enemie
local sword_sprite
-- mouvement de l'enemie
local movement
-- Event called when the enemy is initialized.
function enemy:on_created()
-- On crée le sprite du corps de l'enemie en fonction de la race de l'enemie (nommage formalisé)
body_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed())
-- On crée le sprite de l'épée de l'enemie en fonction de la race de l'enemie (nommage formalisé)
sword_sprite = enemy:create_sprite("enemies/" .. enemy:get_breed().."_sword")
-- On parametre les points de vie à l'enemie
enemy:set_life(5)
-- On parametre les dégats en pts de vie qu'inflige l'enemie
enemy:set_damage(1)
-- On parametre que l'enemie est repoussé quand il touché
enemy:set_pushed_back_when_hurt(true)
-- On parametre que le sprite épée est invincible
self:set_invincible_sprite(sword_sprite)
-- On parametre que le sprite épée quand il recoit une attaque de type "sword" déclenche l'evenement enemy:on_custom_attack_received
self:set_attack_consequence_sprite(sword_sprite, "sword", "custom")
end
-- Event called when the enemy should start or restart its movements.
-- This is called for example after the enemy is created or after
-- it was hurt or immobilized.
function enemy:on_restarted()
print("restarted")
-- On crée un mouvement de type "target"
movement = sol.movement.create("target")
-- On param que la cible de ce mouvement est le héro
movement:set_target(hero)
-- On param la vitesse du mouvement enemie
movement:set_speed(10)
-- On affecte le mouvement à l'enemie et on le lance
movement:start(enemy)
end
-- LORSQUE L'ENEMIE CHANGE DE DIRECTION
function enemy:on_movement_changed(movement)
print("change direction")
--if not being_pushed then
-- On recupere la direction du mouvement
local direction4 = movement:get_direction4()
-- On represente la nouvelle direction en changeant la direction du sprite du corps de l'enemie
body_sprite:set_direction(direction4)
-- On represente la nouvelle direction en changeant la direction du sprite de l'épée de l'enemie
sword_sprite:set_direction(direction4)
--end
end
-- LORSQUE L'ENEMIE RECOIT UNE ATTAQUE QUE L'ON VEUT GERER SOIT MEME
function enemy:on_custom_attack_received(attack, sprite)
-- Si l'attaque et de type sword et qu'elle touche l'epée enemie
if attack == "sword" and sprite == sword_sprite then
-- On joue le son de choc d'épées
sol.audio.play_sound("sword_tapping")
--being_pushed = true
local x, y = self:get_position()
local angle = self:get_angle(self:get_map():get_entity("hero")) + math.pi
local movement = sol.movement.create("straight")
movement:set_speed(128)
movement:set_angle(angle)
movement:set_max_distance(32)
movement:set_smooth(true)
movement:start(self,self:restart())
end
end
Quote from: Realguigui on February 10, 2017, 10:50:47 AM
The solution I think to implement:
- Create the big key in the editor and disable it.
- Transmit to my function "fall" the var "large key" to reactivate it rather than create it.
Quote from: MetalZelda on February 08, 2017, 09:35:57 PM
In your item script, you just need
function item:on_obtaining(variant, savegame_variable)
your_code
end
But, on_obtaining is called when you get that treasure, that is, before the treasure text begins.
You should use item:on_obtained() instead, or item:on_using()
Quote from: Diarandor on January 28, 2017, 11:33:06 PM
It seems that the correct origin for zsdx is (0, 0), so that was not the problem, I think. I don't know yet what the problem is. Are you using both the last version of the game zsdx and the last version of the engine?
Another remark: after you modify the origin of the sprite, the refreshing button of the open map will not show the changes; you can either close/reopen the map, or double click in the switch entity and click "ok", that will show the updated origin for the switch sprite. Make sure you refresh the map to see how the changes are for that origin point.
Another question: is the size of your switch sprite 16x16?
Quote from: Christopho on January 28, 2017, 09:28:01 PMit's worst, the bounding box is completly offset:
Try to set the origin point of the switch sprite to 8,13.