2017-06-14 99 views
1

所以我在遊戲製作工作室2製作遊戲,它有點像足球,但有飛行。我只是做了運動和噴氣揹包的控制,昨天晚上它正在工作,但是當我今天早上啓動它時,發生了這種情況。通常當你移動時,你只能看到一個圖像(精靈),但它顯示了它的位置並將圖像留在那裏。我不知道這是RAM錯誤還是我在代碼中做了錯誤。爲什麼精靈的「幽靈」會被困在背景中? GMS 2

代碼:播放器對象 步驟事件

/// @description Movement logic 
// Get the input 
var x_input = (keyboard_check(vk_right) - keyboard_check(vk_left)) * acceleration_; 

// Vector variables 
var vector2_x = 0; 
var vector2_y = 1; 

// Horizontal movement 
velocity_[vector2_x] = clamp(velocity_[vector2_x]+x_input, -max_velocity_[vector2_x], max_velocity_[vector2_x]); 
var on_ground = tile_collide_at_points(collision_tile_map_id_, [bbox_left, bbox_bottom], [bbox_right-1, bbox_bottom]); 
if keyboard_check(vk_right){ 
    if on_ground { 
    sprite_index = spr_player_ground_right 
    direction_=0 
    } 
    else { 
    sprite_index = spr_player_flying_right 
    direction_=0 
    } 
} 

if keyboard_check(vk_left){ 
    if on_ground { 
    sprite_index = spr_player_ground_left 
    direction_=1 
    } 
    else { 
    sprite_index = spr_player_flying_left 
    direction_=1 
    } 
} 

// Friction 
if x_input == 0 { 
    velocity_[vector2_x] = lerp(velocity_[vector2_x], 0, .2); 
} 


// Gravity 
velocity_[vector2_y] += gravity_; 

// Move and contact tiles 
move_and_contact_tiles(collision_tile_map_id_, 64, velocity_); 

// Jumping 
var on_ground = tile_collide_at_points(collision_tile_map_id_, [bbox_left, bbox_bottom], [bbox_right-1, bbox_bottom]); 
//if on_ground { 
    // Jumping 
    if keyboard_check(vk_space) { 
     velocity_[vector2_y] = -jump_speed_; 
     if direction_=0 { 
     sprite_index = spr_player_flying_right 
     direction_=0 
     } 
     else { 
     sprite_index = spr_player_flying_left 
     direction_=1 
     } 
    } 
//} 

播放器對象

/// @description Movement variables 
velocity_ = [0, 0]; 
gravity_ = 0.3; 
jump_speed_ = 4; 
max_velocity_ = [8, 32]; 
acceleration_ = 2.1; 
direction_ = 0; 

// Get the tilemap id 
var layer_id = layer_get_id("CollisionTiles"); 
collision_tile_map_id_ = layer_tilemap_get_id(layer_id); 

創建活動我覺得應該代碼覆蓋它。

任何幫助表示讚賞!

回答

2

您是否在當前繪製背景的房間中禁用了此複選框? 如果這樣只是重新檢查它。

注意這是gm8,但它應該是相同的。

Check Draw Backgrund

+0

我發現每當我選擇spr_crowd精靈,它留下了「鬼」。我怎麼能解決這個問題? –

+0

你提供的東西不足以幫助我,至少我需要屏幕截圖。 – Daedric

+0

這是背景故障,圖像沒有填滿屏幕,所以「鬼」效應發生。謝謝你的幫助! –