Bonjours/Bonsoir
je suis après suivre un Tutorial sur youtube qui est sur GMS et moi je travail sur la deuxième version (GMS2)
mon probleme c'est que je veux faire un dash comme dans cette vidéo avec un effet de transparence @
https://www.youtube.com/watch?v=EvYXRefDQHU 22m11
une fois que je rentre cette ligne de code je reçois un message d'erreur
Script: scr_dash_state at line 20 : unknown function or script instance_create
il dit qu'il y a un problème à la ligne 20 mais ne je n'ai que 16 lignes de code dans mon scr_dash_state et si j’enlève cette partie du code le personnage dash super-bien sauf qu'il n'a pas l'effet que je veux.
- Code:
-
var dash = instance_create(x, y, obj_dash_effect);
dash.sprite_index = sprite_index;
dash.image_index = image_index;
donc je vais poster le tout ici au propre
obj_player
create
- Code:
-
/// set fixed rotation
phy_fixed_rotation = true;
spd = 4;
hsped = 0;
vspd = 0;
xaxis = 0;
yaxis = 0;
len = 0;
dir = 0;
image_speed = 0;
scr_get_input();
state = scr_move_state;
step
- Code:
-
/// Move the player in the step event
script_execute(state);
Alarm 0
- Code:
-
/// this alarm is for the dash state
state = scr_move_state;
ceci est l'objet en question qui va créer mon effet de duplication quand je vais courir.
obj_dash_effect
create
- Code:
-
/// initialize the dash effect
image_alpha = .5;
step
- Code:
-
/// fade
if (image_alpha > 0) {
image_alpha -= .1;
} else {
instance_destroy();
}
donc voici mes 3 scripts
celui-ci c'est pour mes contrôles manette clavier
scr_get_input
- Code:
-
///scr_get_input
W_key = keyboard_check(ord("W"));
S_key = keyboard_check(ord("S"));
A_key = keyboard_check(ord("A"));
D_key = keyboard_check(ord("D"));
dash_key = keyboard_check(ord("C"));
// Get the axis
xaxis = (D_key - A_key);
yaxis = (S_key - W_key);
// check for gamepad input
if (gamepad_is_connected(0)) {
gamepad_set_axis_deadzone(0, .30);
xaxis = gamepad_axis_value(0, gp_axislh);
yaxis = gamepad_axis_value(0, gp_axislv);
dash_key = gamepad_button_check_pressed(0,gp_face3)
}
script pour déplacement de l'obj_player l'important c'est entre la ligne 4 et 7
- Code:
-
///scr_move_state
scr_get_input();
if (dash_key){
state = scr_dash_state;
alarm[0] = room_speed/6;
}
// Get direction
dir = point_direction(0, 0, xaxis, yaxis);
//Get the length
if (xaxis == 0 and yaxis = 0) {
len = 0;
} else {
len = spd;
}
// Get the hspd and vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
//Move
phy_position_x += hspd;
phy_position_y += vspd;
// control the sprite
image_speed = .2;
if (len == 0) image_index = 0;
// Vertical sprite
if (vspd > 0) {
sprite_index = spr_player_b;
} else if ( vspd < 0) {
sprite_index = spr_player_h;
}
// Horizontal sprite
if (hspd > 0) {
sprite_index = spr_player_d;
} else if ( hspd < 0) {
sprite_index = spr_player_g;
}
la ligne de code qui me pose problème est entre la 14 a 16 pourtant dans la vidéo j'ai bien repris ce qui a fait
scr_dash_state
- Code:
-
len = spd*4;
// get the hspd and vspd
hspd = lengthdir_x(len, dir);
vspd = lengthdir_y(len, dir);
// move
phy_position_x += hspd;
phy_position_y += vspd;
// create the dash effect
var dash = instance_create(x, y, obj_dash_effect);
dash.sprite_index = sprite_index;
dash.image_index = image_index;
j’espère que c'est assez claire comme information sinon je ferais des photo ou une vidéo.