I have been watching Friendly Cosmonaut video on creating a Dialogue System and building a Cutscene System, I attempted to to combine the two ideas together and it works (sort of). There a couple Technical Hiccups I tried to sort out but it seems out of my grasp.
In the creation code where it runs all of the arrays it should immediately end the action rather it loops through the last dialogue rather than ending it and moving to next cutscene action.
The arguments transfer the strings and sprite of desired profile picture into obj_cutsceneDialogue, with the created object it creates an Dialogue box which both the string and profile appear respectively.
The second issue is that the text overlap one another, strangely it still continues to borrow text from the previous cutscene event even thought it should have finish and not borrow the old text.
Here is the creation code for the trigger that activates the cutscene:
Here is the cutsceneDialogue that script creates
Create_Event:
Step_Event:
Alarm 0:
MyTextbox = noone;
complete = true;
Alarm 1:
playing = 1;
Here is the Scripts for obj_cutDialogue the dialogue box created by obj_cutsceneDialogue
Create_Event:
Step_Event:
Draw_Event:
It should be noted that page variable is omitted out of the script due to it causing frequent crashing.
In the creation code where it runs all of the arrays it should immediately end the action rather it loops through the last dialogue rather than ending it and moving to next cutscene action.
GML:
function cutscene_dialogue(){
var created = false; //<--- Check to see if object exists
if created = false{
instance_create_layer(view_visible[0], view_visible[0], "Instances", obj_cutsceneDialogue); //<--- Create the object
created = true;
}
with (obj_cutsceneDialogue){
obj_cutsceneDialogue.cutText = argument0;
obj_cutsceneDialogue.cutProfile = argument1;
}
if (obj_cutsceneDialogue.complete = true && created = true){ //<--- Checks to see if the Dialogue is complete and ends the cutscene
instance_destroy(); //<---This prevents the game from crashing for some reason.
with (obj_cutsceneDialogue){instance_destroy(obj_CutDialogue);}
cutscene_end_action(); //<---End the action and move on to the next cutscene event.
}
}
The second issue is that the text overlap one another, strangely it still continues to borrow text from the previous cutscene event even thought it should have finish and not borrow the old text.
Here is the creation code for the trigger that activates the cutscene:
Code:
t_scene_info =[
[cutscene_dialogue, "That was strange?", spr_profile_none],
[cutscene_dialogue, "He was here for a second.", spr_profile_none],
];
Create_Event:
Code:
//Initalize Varibles
MyTextbox = noone;
complete = false; //<--- Checks to see if the Dialogue is completed.
playing = false;
Code:
if playing = false alarm[1] = 1; //<--- Auto plays the Dialogue Box
if MyTextbox = noone{
if playing = true{
MyTextbox = instance_create_layer(view_visible[0], view_visible[0], "Instances", obj_CutDialogue);
MyTextbox.text = cutText;
MyTextbox.profile = cutProfile;
MyTextbox.creator = self;
}else{
//Reset Varible
if MyTextbox != noone {
instance_destroy(MyTextbox);
}
}
}
MyTextbox = noone;
complete = true;
Alarm 1:
playing = 1;
Here is the Scripts for obj_cutDialogue the dialogue box created by obj_cutsceneDialogue
Create_Event:
Code:
///scr_textbox_create_script
depth = -1;
//Initalize Varibles
text = "This is a Text";
profile = spr_profile_none;
//Text Positioning
Box_width = sprite_get_width(spr_DialogueBox);
String_height = string_height(text);
charCount = 0;
//Pages
//page = 0;
//Creator
creator = noone;
//Image Index
frame = image_index;
//Animation
FrameSpeed = 0.05;
Code:
//scr_textbox_step_script
//Interact button
if keyboard_check_pressed(ord("X"))
{
instance_destroy();
creator.alarm[0] = 1;
}
//Increase Frame via FrameSpeed
frame += FrameSpeed;
//Profile Animation
if (floor(frame) > sprite_get_number(profile) - 1)
{
frame = 0;
}
Code:
///scr_textbox_draw_script
//Creating Textbox
draw_sprite_ext(spr_DialogueBox, 0, view_visible[0], view_visible[0], 1.98, 1.50, 0,c_white,1);
//Creating Text
draw_set_halign(fa_left);
draw_set_font(txt_font_1);
draw_set_color(c_white);
draw_set_alpha(1);
if (charCount < string_length(text))
{
charCount += 0.40;
}
TextPart = string_copy(text, 1, charCount)
draw_text_ext(view_visible[0] + 50, view_visible[0] + 50, TextPart, String_height, Box_width);
//Creating Portrait
draw_sprite_ext(profile, frame,view_visible[0] + 32,view_visible[0] + 68,1,1,0,c_white,1);