Masks verursachen Draw Fehler

  • GM 7
  • Masks verursachen Draw Fehler

    Hey,

    ich feilsche nun schon glaub ich gut 2 Wochen an dem Problem rum... Also folgendes Problem: Sagen wir jetzt einfach mal ich hab ein Sprite für eine Mask und ein anderes für eine andere, kleinere. Wenn ich springe, wird die Mask auf die kleinere umgelegt und beim Landen wieder zurück. Anscheinend wird das Sprite vor der Mask zurück geändert, weil ich anscheinend in den Boden gezeichnet werde.

    Ich hab es in dieser Reihenfolge:

    • Step: Koordinaten runden, Gravitation, Steuerung, Kollisionen, Mask Setzung, Movement
    • Collision Events: Weitere Kollisionen
    • Draw: Auslesung der Variablen zur Spritesetzung, Zeichnen der Sprites

    Was ich schon versucht habe:

    • Kollisionen ins Step
    • Mask-Setzung ins Begin Step und an den Anfang bzw. nach der Spritesetzung ins Draw
    Ich bin so verzweifelt, ich kriegs einfach nicht hin.
    Solltet ihr mehr Informationen brauchen, hier sind alle Informationen für den Player:

    Spoiler anzeigen
    Information about object: obj_sonic

    Sprite: spr_sonic
    Solid: false
    Visible: true
    Depth: 0
    Persistent: false
    Parent: <no parent>
    Mask: mask_sonic

    Create Event:
    execute code:

    xspeed = 0;
    yspeed = 0;
    grav = 0;
    xscale = 1;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    hit = 0;
    invincible = 0;
    countdown = 10;
    rings = 0;
    shield = 0;
    invincibility = 0;
    shieldindex = 0;
    move = 0;
    goal = 1;
    win = 0;
    sprite = spr_sonic;

    if (global.startx != -1) {x = global.startx;}
    if (global.starty != -1) {y = global.starty;}

    instance_create(0,0,obj_hud);
    instance_create(0,0,obj_bg);
    instance_create(0,200,obj_starter);

    view_object = id;

    Alarm Event for alarm 0:
    execute code:

    image_alpha = 0;
    alarm[1] = 4;

    Alarm Event for alarm 1:
    execute code:

    image_alpha = 1;
    if (countdown > 0) {
    countdown -= 1;
    alarm[0] = 4;
    }
    else {
    countdown = 10;
    invincible = 0;
    }

    Alarm Event for alarm 2:
    execute code:

    invincibility = 0;
    global.music = global.tempmusic;

    Alarm Event for alarm 3:
    execute code:

    shieldindex += 1;
    if (shieldindex > 5) {shieldindex -= 5;}
    if (shield > 0 || invincibility) {alarm[3] = 4;}

    Step Event:
    execute code:

    x = round(x);

    if (collision_line(x,bbox_bottom+1,x+19,bbox_bottom+1,obj_jt_block,1,1) && yspeed >= 0) {
    grav = 0;
    if (win == 1) {win = 2;}
    }
    else {grav = 0.25;}

    if (keyboard_check(vk_left) && !place_meeting(x-1,y,obj_block) && !duck && !roll && !hit && move && win == 0) {
    if (xspeed > -8) {xspeed -= 0.1;}
    xscale = -1;
    }
    if (keyboard_check(vk_right) && !place_meeting(x+1,y,obj_block) && !duck && !roll && !hit && move && win == 0) {
    if (xspeed < 8) {xspeed += 0.1;}
    xscale = 1;
    }
    if ((!(keyboard_check(vk_left) ^^ keyboard_check(vk_right)) || roll || win != 0) && !hit) {
    if (xspeed >= -0.1 && xspeed <= 0.1) {xspeed = 0;}
    if (xspeed > 0.1) {xspeed -= 0.1;}
    if (xspeed < -0.1) {xspeed += 0.1;}
    }

    if (place_meeting(x+xspeed,y,obj_block)) {
    move_contact_all(point_direction(0,0,xspeed,0),xspeed);
    xspeed = 0;
    }
    if (place_meeting(x+xspeed,y,obj_box_5_rings) && !jump && !roll) {
    move_contact_all(point_direction(0,0,xspeed,0),xspeed);
    xspeed = 0;
    }

    ID = collision_rectangle(x,bbox_bottom+1,x+19,bbox_bottom+1,obj_spikes,1,1);
    if (ID) {
    y = ID.y-sprite_get_bbox_bottom(mask_index)+5;
    if (!invincibility && !invincible) {
    if (shield > 0) {
    xspeed = xscale*(-2);
    yspeed = -5;
    hit = 1;
    shield = 0;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    invincible = 1;
    sound_play(snd_dead);
    }
    else if (rings > 0) {
    xspeed = xscale*(-2);
    yspeed = -5;
    hit = 1;
    if (rings > 20) {rings = 20;}
    repeat (rings) {instance_create(x+6,y+12,obj_hit_ring);}
    rings = 0;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    invincible = 1;
    sound_play(snd_hurt);
    }
    else {
    instance_destroy();
    instance_create(x,y,obj_sonic_dead);
    sound_play(snd_dead);
    }
    }
    else {
    yspeed = 0;
    grav = 0;
    jump = 0;
    if (hit) {
    hit = 0;
    alarm[0] = 4;
    }
    }
    }

    if (keyboard_check(vk_down) && collision_rectangle(x,bbox_bottom+1,x+19,bbox_bottom+1,obj_jt_block,1,1) && move && win == 0) {
    if (xspeed == 0) {duck = 1;}
    else if (!roll) {
    roll = 1;
    sound_stop(snd_spin_dash);
    sound_play(snd_spin_dash);
    }
    }
    if (keyboard_check_released(vk_down)) {
    duck = 0;
    if (spindash) {
    if (!place_meeting(x+xscale*8,y,obj_block)) {xspeed = xscale*8;}
    else {move_contact_all(point_direction(0,0,xscale*8,0),xscale*8);}
    spindash = 0;
    roll = 1;
    sound_play(snd_spin_dash);
    }
    }

    if (keyboard_check_pressed(vk_space) && collision_line(x,bbox_bottom+1,x+19,bbox_bottom+1,obj_jt_block,1,1) && yspeed >= 0 && move && win == 0) {
    if (duck) {
    spindash = 1;
    sound_play(snd_spin_dash);
    }
    else {
    yspeed = -6;
    jump = 1;
    sound_play(snd_jump);
    }
    }

    if (xspeed == 0) {roll = 0;}

    if (xspeed > 8) {xspeed = 8;}
    if (xspeed < -8) {xspeed = -8;}
    if (yspeed > 8) {yspeed = 8;}

    if (!place_meeting(x,y,obj_goal_post)) {goal = 1;}

    if (duck || jump || roll) {
    if (mask_index == mask_sonic) {
    mask_index = mask_sonic_spin;
    y += 12;
    }
    }
    else if (mask_index == mask_sonic_spin) {
    mask_index = mask_sonic;
    y -= 12;
    }

    x += xspeed;
    y += yspeed;
    yspeed += grav;

    End Step Event:
    execute code:

    if (x < view_xview) {
    x = view_xview;
    xspeed = 0;
    }
    if (x > room_width-19) {
    x = room_width-19;
    xspeed = 0;
    }

    Collision Event with object obj_jt_block:
    execute code:

    if (yprevious+sprite_get_bbox_bottom(mask_index) <= other.y) {
    y = other.y-sprite_get_bbox_bottom(mask_index)-1;
    yspeed = 0;
    grav = 0;
    jump = 0;
    if (hit) {
    hit = 0;
    alarm[0] = 4;
    }
    sound_play(snd_land);
    }

    Collision Event with object obj_block:
    execute code:

    if (yprevious+sprite_get_bbox_bottom(mask_index) <= other.y) {
    y = other.y-sprite_get_bbox_bottom(mask_index)-1;
    yspeed = 0;
    jump = 0;
    grav = 0;
    if (hit) {
    hit = 0;
    alarm[0] = 4;
    }
    }
    if (yspeed < 0) {
    y = other.y+32;
    yspeed = 0;
    sound_play(snd_land);
    }

    Collision Event with object obj_spring:
    execute code:

    if (yprevious+sprite_get_bbox_bottom(mask_index) <= other.y+6) {
    y = other.y-sprite_get_bbox_bottom(mask_index)+5;
    yspeed = -7;
    jump = 0;
    if (hit) {
    hit = 0;
    alarm[0] = 4;
    }
    other.image_speed = 0.5;
    sound_play(snd_spring);
    }

    Collision Event with object obj_spring_red:
    execute code:

    if (yprevious+sprite_get_bbox_bottom(mask_index) <= other.y+2) {
    y = other.y-sprite_get_bbox_bottom(mask_index)+1;
    yspeed = -10;
    jump = 0;
    if (hit) {
    hit = 0;
    alarm[0] = 4;
    }
    other.image_speed = 0.5;
    sound_play(snd_spring);
    }

    Collision Event with object obj_ring:
    execute code:

    if (!hit) {
    with (other) {instance_destroy();}
    rings += 1;
    sound_play(snd_ring);
    }

    Collision Event with object obj_spikes:
    execute code:

    //This event just needs to contain something.

    Collision Event with object obj_box_5_rings:
    execute code:

    if (jump || roll) {
    with (other) {instance_destroy();}
    if (yspeed >= 0) {yspeed = -5;}
    sound_play(snd_destroy);
    }
    else {
    if (yprevious+sprite_get_bbox_bottom(mask_index) <= other.y+3) {
    y = other.y-sprite_get_bbox_bottom(mask_index)+2;
    yspeed = 0;
    grav = 0;
    jump = 0;
    if (hit) {
    hit = 0;
    invincible = 1;
    alarm[0] = 4;
    }
    sound_play(snd_land);
    }
    }

    Collision Event with object par_enemy:
    execute code:

    if (roll || jump || spindash || invincibility) {
    instance_create(other.x+sprite_get_bbox_right(other.sprite_index)/2,other.y+sprite_get_bbox_bottom(other.sprite_index)/2,obj_smoke);
    with (other) {instance_destroy();}
    global.points += 100;
    if (yspeed >= 0) {yspeed = -5;}
    sound_play(snd_destroy);
    }
    else if (!invincible) {
    if (shield > 0) {
    xspeed = xscale*(-2);
    yspeed = -5;
    hit = 1;
    shield = 0;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    invincible = 1;
    sound_play(snd_dead);
    }
    else if (rings > 0) {
    xspeed = xscale*(-2);
    yspeed = -5;
    hit = 1;
    if (rings > 20) {rings = 20;}
    repeat (rings) {instance_create(x+6,y+12,obj_hit_ring);}
    rings = 0;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    invincible = 1;
    sound_play(snd_hurt);
    }
    else {
    instance_destroy();
    instance_create(x,y,obj_sonic_dead);
    sound_play(snd_dead);
    }
    }

    Collision Event with object par_shot:
    execute code:

    if (!invincibility && !invincible) {
    if (shield > 0) {
    xspeed = xscale*(-2);
    yspeed = -5;
    hit = 1;
    shield = 0;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    invincible = 1;
    sound_play(snd_dead);
    }
    else if (rings > 0) {
    xspeed = xscale*(-2);
    yspeed = -5;
    hit = 1;
    if (rings > 20) {rings = 20;}
    repeat (rings) {instance_create(x+6,y+12,obj_hit_ring);}
    rings = 0;
    jump = 0;
    duck = 0;
    roll = 0;
    spindash = 0;
    invincible = 1;
    sound_play(snd_hurt);
    }
    else {
    instance_destroy();
    instance_create(x,y,obj_sonic_dead);
    sound_play(snd_dead);
    }
    }

    Collision Event with object obj_emblem:
    execute code:

    if (!hit) {
    with (other) {instance_destroy();}
    global.points += 100;
    }

    Collision Event with object obj_check_point:
    execute code:

    if (other.sprite_index == spr_check_point && other.image_speed == 0) {
    other.image_speed = 0.5;
    global.startx = other.x+4;
    global.starty = other.y+32;
    sound_play(snd_check_point);
    }

    Collision Event with object obj_goal_post:
    execute code:

    if (goal) {
    other.xspeed = -2+random(4);
    other.yspeed = -5;
    other.grav = 0.125;
    other.image_speed = 0.5;
    goal = 0;
    global.points += 10;
    instance_create(x+10,other.y-16,obj_view);
    view_object = obj_view;
    if (!instance_exists(obj_emblem)) {global.emblem[global.level] = 1;}
    sound_play(snd_goal_post);
    }

    Collision Event with object obj_dash_panel:
    execute code:

    xspeed = 8;
    if (!sound_isplaying(snd_dash_panel)) {sound_play(snd_dash_panel);}

    Draw Event:
    execute code:

    sprite_index = sprite;
    if (win == 2 && xspeed == 0) {
    if (sprite != spr_sonic_goal) {
    image_index = 0;
    global.music = snd_act_clear;
    }
    if (image_index >= 17) {image_single = 17;}
    }

    image_speed = 0.25;
    if (collision_line(x,bbox_bottom+1,x+19,bbox_bottom+1,obj_jt_block,1,1) && yspeed >= 0) {
    if (xspeed == 0) {
    if (win == 2) {sprite = spr_sonic_goal;}
    else if (spindash) {sprite = spr_sonic_spin_dash;}
    else if (duck) {sprite = spr_sonic_duck;}
    else {sprite = spr_sonic;}
    }
    else {
    if (roll) {sprite = spr_sonic_jump;}
    else if (((xspeed > 0 && keyboard_check(vk_left) && !keyboard_check(vk_right)) || (xspeed < 0 && keyboard_check(vk_right) && !keyboard_check(vk_left))) && win == 0) {
    sprite = spr_sonic_skid;
    sound_play(snd_break);
    }
    else if (xspeed == xscale*8) {sprite = spr_sonic_run;}
    else {sprite = spr_sonic_walk;}
    image_speed = xspeed/8;
    }
    }
    else {
    if (hit) {sprite = spr_sonic_hit;}
    else if (jump) {sprite = spr_sonic_jump;}
    else {
    sprite = spr_sonic_spring;
    if (yspeed < 0) {image_single = 0;}
    else {image_single = 1;}
    }
    }

    if (shield == 1) {draw_sprite(spr_shield,shieldindex,x+10,bbox_bottom-16);}
    if (shield == 2) {draw_sprite(spr_magnetic_shield,shieldindex,x+10,bbox_bottom-16);}
    draw_sprite_ext(sprite,image_index,x+10,y,xscale,1,0,c_white,image_alpha);
    if (invincibility) {draw_sprite(spr_invincibility,shieldindex,x+10,bbox_bottom-16);}
    :| < Hallo. Nein ich bin nicht die Signatur, ich putze hier nur.
  • Okay, ich habs jetzt mit nem Workaround gelöst. Ich zeichne nun von bbox_bottom und nicht mehr von y aus.
    :| < Hallo. Nein ich bin nicht die Signatur, ich putze hier nur.