YoSniper
Member
I am programming a game where a player collects coins. Collecting ten coins without a miss is meant to incur a "streak" bonus. This will be represented by an object that displays text next to the score HUD that rises and fades away.
Score is kept by a singular persistent object called World. Up until this point, the score has been kept very well. My problems only arise with the StreakBonus object, which for some reason cannot be created.
Here is the relevant code for the Collectible object (coin).
And here is the ScoreEffect create event. It includes a debug prompt confirming that the instance has been created, and this never shows up.
Can someone tell me why the StreakBonus object is not being created? I have confirmed that the conditions for the code block are met.
[EDIT] Found the issue. Was trying to create to a layer rather than using instance_create_depth.
Score is kept by a singular persistent object called World. Up until this point, the score has been kept very well. My problems only arise with the StreakBonus object, which for some reason cannot be created.
Here is the relevant code for the Collectible object (coin).
Code:
//Interaction with player or boundary
if place_meeting(x, y, Player) {
if Player.powerup == "MULTIPLIER" {
World.current_score += 2;
} else {
World.current_score += 1;
}
World.current_streak += 1;
//--- FOR SOME REASON, THE FOLLOWING BLOCK DOES NOT GET EXECUTED ---
if World.current_streak mod 10 == 0 {
//Add a bonus score for streak
instance_create_layer(room_width - 160, 40, 0, StreakBonus);
}
//--- END ERROR
if World.high_score < World.current_score {
World.high_score = World.current_score;
}
instance_destroy();
}
Code:
/// @description Set value, alpha
bonus = World.current_streak / 10;
World.current_score += bonus;
alpha = 1;
depth = -15;
//DEBUG
show_message("Streak bonus created")
[EDIT] Found the issue. Was trying to create to a layer rather than using instance_create_depth.
Last edited: