| | [Résolu] Problème avec le chargement d'objets dont le code est externe | |
| | Auteur | Message |
---|
GDOR1 Très bonne participation
Messages : 130
| Sujet: [Résolu] Problème avec le chargement d'objets dont le code est externe Lun 19 Nov 2012 - 15:53 | |
| Bonjour! J'ai encore un problème ! Quand je veux charger un objet dont le code est dans un fichier texte, il n'execute que l' envent create, pas les autres ! Dans le fichier texte, les events sont fait avec cette action: object_event_add. Comment je pourrais faire pour que l'objet n'execute pas que l'event create, mais aussi les autres?
Dernière édition par GDOR1 le Lun 3 Déc 2012 - 19:48, édité 1 fois |
| | | Térence Utilisateur confirmé: Rang *****
Messages : 2213 Localisation : Oui
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Lun 19 Nov 2012 - 18:21 | |
| Sans code on peut pas beaucoup t'aider tu sais... |
| | | GDOR1 Très bonne participation
Messages : 130
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Lun 19 Nov 2012 - 19:12 | |
| Voici mon code: - Code:
-
global.obj_prehistoric_bowmen = object_add()
//Create event object_event_add(global.obj_prehistoric_bowmen,ev_create,0,"//Graphics variables sprite_index = global.bowmen_sprite image_speed = 0 selected = false move_x = x move_y = y
//Paths path = path_add()
//Sprite sprite_set_offset(sprite_index,sprite_width/2/14,sprite_height/2)
//Instances instance_create(x,y,obj_bowmen_visibility)")
//Step event object_event_add(global.obj_prehistoric_bowmen,ev_step,1," if mouse_check_button_pressed(mb_left) {
//Control key (don't delete selection) if not keyboard_check(vk_control) { selected = false }
}
if mouse_check_button(mb_left) {
//Selection if not global.pause = true { if selected = false { if x > obj_select.x if y > obj_select.y if x < mouse_x if y < mouse_y { selected = true }
if x < obj_select.x if y < obj_select.y if x > mouse_x if y > mouse_y { selected = true }
if x > obj_select.x if y < obj_select.y if x < mouse_x if y > mouse_y { selected = true }
if x < obj_select.x if y > obj_select.y if x > mouse_x if y < mouse_y { selected = true }
} } }
//Mouse if mouse_check_button_pressed(mb_right) {
if selected = true { move_x = mouse_x move_y = mouse_y alarm[0] = 1 }
}
//Path mp_grid_add_instances(global.path_grid,id,false)
if alarm = 0 { path_end() alarm[0] = global.refresh_rate_path
mp_grid_clear_rectangle(global.path_grid,x - 20,y - 20,x + 20,y + 20)
if not mp_grid_path(global.path_grid,path,x,y,move_x,move_y,true) { speed = 0 } else { mp_grid_path(global.path_grid,path,x,y,move_x,move_y,true) path_set_kind(path,1) path_set_precision(path,global.path_precision) path_start(path,4,0,false) }
mp_grid_add_instances(global.path_grid,id,false) }
//Angle of image image_angle = direction")
//Draw event object_event_add(global.obj_prehistoric_bowmen,ev_draw,2," draw_sprite_ext(sprite_index,image_index,x,y,1,1,image_angle,c_white,1)
//Path debug if selected = true if global.debug = true { draw_set_color(c_blue) draw_path(path,x,y,true) }") Je ne pensais pas que ça pouvait beaucoup, je cherche juste s'il y a un moyen d'obliger l'instance à executer les events... |
| | | GDOR1 Très bonne participation
Messages : 130
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Sam 24 Nov 2012 - 11:32 | |
| Up ! C'est pour rendre un jeu moddable ! Comment je dois m'y prendre, avec les event_perform, ou pas ? |
| | | SPLN Utilisateur confirmé: Rang ***
Messages : 588 Localisation : Sur son ordinateur *vous vois* arrêtez de me regarder comme ça Projet Actuel : En quête de projet(s)!
Mes projets:
SP Lecteur Multimedia (Stand by)
S-Portable Graphics (demo1.8 is out! demo2.0 is planned)
SSB RPG (Stand by)
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Sam 24 Nov 2012 - 22:44 | |
| event_perform() c'est pour exécuter un event donc non ça n'en créera pas un. C'est bien object_event_add(ind,evtype,evnumb,codestr) qu'il faut utiliser. Pour trouver les constantes relatives à evtype et evnumb, va dans la section "Generating events" de la doc de Game Maker. Alors si je dis pas de bêtise, en reprenant ton code ça donnerais quelque chose du genre : - Ev. Create : object_event_add( global.obj_prehistoric_bowmen, ev_create, 0, str ) - Ev. Step : object_event_add( global.obj_prehistoric_bowmen, ev_step, ev_step_normal, str ) - Ev. Draw : object_event_add( global.obj_prehistoric_bowmen, ev_draw, 0, str ) Avec str le string contenant ton code. Si tu as la flemme j'ai copié la doc (en anglais), en espérant qu'elle ne soit pas tronquée : - Spoiler:
As you know, Game Maker is completely event driven. All actions happen as the result of events. There are a number of different events. Creation and destroy events happen when an instance is created or destroyed. In each step, the system first handles the begin step events. Next it handles the alarm events, keyboard and mouse events and next the step event. After this the instances are set to their new positions after which the collision event is handled. Finally the end step events are handled after which the draw event is used to draw the instances (note that when there are multiple views the draw event is called multiple times in each step). You can also apply an event to the current instance from within a piece of code. The following functions exist:
event_perform(type,numb) Performs event numb of the indicated type to the current instance. The following event types can be indicated:
ev_create ev_destroy ev_step ev_alarm ev_keyboard ev_mouse ev_collision ev_other ev_draw ev_keypress ev_keyrelease ev_trigger
When there are multiple events of the given type, numb can be used to specify the precise event. For the event type ev_alarm numb can range from 0 to 11. For the ev_keyboard, ev_keypress. and ev_keyrelease event types you have to use the keycode for the key. For ev_mouse events you can use for numb the following constants:
ev_left_button ev_right_button ev_middle_button ev_no_button ev_left_press ev_right_press ev_middle_press ev_left_release ev_right_release ev_middle_release ev_mouse_enter ev_mouse_leave ev_mouse_wheel_up ev_mouse_wheel_down ev_global_left_button ev_global_right_button ev_global_middle_button ev_global_left_press ev_global_right_press ev_global_middle_press ev_global_left_release ev_global_right_release ev_global_middle_release ev_joystick1_left ev_joystick1_right ev_joystick1_up ev_joystick1_down ev_joystick1_button1 ev_joystick1_button2 ev_joystick1_button3 ev_joystick1_button4 ev_joystick1_button5 ev_joystick1_button6 ev_joystick1_button7 ev_joystick1_button8 ev_joystick2_left ev_joystick2_right ev_joystick2_up ev_joystick2_down ev_joystick2_button1 ev_joystick2_button2 ev_joystick2_button3 ev_joystick2_button4 ev_joystick2_button5 ev_joystick2_button6 ev_joystick2_button7 ev_joystick2_button8 For the collision event you give the index of the other object. For the event type ev_other you can use for numb the following constants:
ev_outside ev_boundary ev_game_start ev_game_end ev_room_start ev_room_end ev_no_more_lives ev_no_more_health ev_animation_end ev_end_of_path ev_close_button ev_user0 ev_user1 ev_user2 ev_user3 ev_user4 ev_user5 ev_user6 ev_user7 ev_user8 ev_user9 ev_user10 ev_user11 ev_user12 ev_user13 ev_user14 ev_user15
For the ev_step event type you can use the following constants for numb:
ev_step_normal ev_step_begin ev_step_end
Finally for the ev_trigger event type you should use the constants that you can specify when defining these events. event_perform_object(obj,type,numb) This functions works the same as the function above except that this time you can specify events in another object. Note that the actions in these events are applied to the current instance, not to instances of the given object! event_user(numb) In the other events you can also define 16 user events. These are only performed if you call this function. numb must lie in the range 0 to 15. event_inherited() Performs the inherited event. This only works if the instance has a parent object.
You can get information about the current event being executed using the following read-only variables:
event_type* Type of the current event begin executed. event_number* Number of the current event begin executed. event_object* The object index for which the current event is being executed. event_action* The index of the action that is currently being executed (0 is the first in the event, etc.).
|
| | | GDOR1 Très bonne participation
Messages : 130
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Lun 26 Nov 2012 - 19:10 | |
| Merci beaucoup ! Mais ...... Ca marche toujours pas ! En tout cas merci d'avoir copié la doc car, c'est pas que j'ai la flemme, c'est que mon navigateur n'arrive pas à l'ouvrir ! |
| | | SPLN Utilisateur confirmé: Rang ***
Messages : 588 Localisation : Sur son ordinateur *vous vois* arrêtez de me regarder comme ça Projet Actuel : En quête de projet(s)!
Mes projets:
SP Lecteur Multimedia (Stand by)
S-Portable Graphics (demo1.8 is out! demo2.0 is planned)
SSB RPG (Stand by)
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Jeu 29 Nov 2012 - 14:08 | |
| C'est bizarre je suis pourtant sûr d'avoir fait ce genre de chose avec ces fonctions quand j'avais besoin de créer un objet à l'aide d'un fichier extérieur. Tu as bien séparés ton code pour chaque event dans des string différents? Ex: str1 pour event create, str2 pour event step, etc... Ensuite est-ce que tu as essayé de voir sur un autre objet avec un code un peu plus simple ? En plus ton code à l'air bon, même si j'aurais tendance à mettre 0 à la place de 2 pour ton event draw. Sinon je vois pas. |
| | | GDOR1 Très bonne participation
Messages : 130
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Sam 1 Déc 2012 - 19:17 | |
| Ah désolé, en fait j'appliquais ce code pour un mauvais objet ! C'est que pour l'event step que ça marche pas maintenant ! Quand je fais ça object_event_add(global.obj_prehistoric_bowmen, ev_step, ev_step_normal,Mes actions) ou object_event_add(global.obj_prehistoric_bowmen, ev_step_normal,0,Mes actions) ça ne marche pas ! Je vais regarder plus tard si ça vient pas de mon code en fait ... Enfin, merci de ton aide en tout cas ! |
| | | SPLN Utilisateur confirmé: Rang ***
Messages : 588 Localisation : Sur son ordinateur *vous vois* arrêtez de me regarder comme ça Projet Actuel : En quête de projet(s)!
Mes projets:
SP Lecteur Multimedia (Stand by)
S-Portable Graphics (demo1.8 is out! demo2.0 is planned)
SSB RPG (Stand by)
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Dim 2 Déc 2012 - 13:27 | |
| - Code:
-
object_event_add(global.obj_prehistoric_bowmen, ev_step, ev_step_normal,"Mes actions") Cela doit surement venir de ton code, tu peux toujours essayer "show_debug_message('TEST')" dans les actions à exécuter dans l'event Step, ce qui te permet d'afficher des messages quand le jeu lorsqu'il est en Debug. Comme ça tu verras tout de suite ce qui cloche. |
| | | GDOR1 Très bonne participation
Messages : 130
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe Lun 3 Déc 2012 - 19:47 | |
| Ah non, en fait c'est bien mon code qui n'était pas bon ! En tout cas, merci de m'avoir aidé ! |
| | | Contenu sponsorisé
| Sujet: Re: [Résolu] Problème avec le chargement d'objets dont le code est externe | |
| |
| | | | [Résolu] Problème avec le chargement d'objets dont le code est externe | |
|
Sujets similaires | |
|
| Permission de ce forum: | Vous ne pouvez pas répondre aux sujets dans ce forum
| |
| |
| |