Skip to content

Commit c600548

Browse files
committed
Cleanup and create entity fix
1 parent 0410b6d commit c600548

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/engine/Component/Sprite.jl

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,22 @@ module SpriteModule
4747
effectTexture::Union{Ptr{Nothing}, Ptr{SDL2.LibSDL2.SDL_Texture}}
4848
needsEffectUpdate::Bool
4949

50-
function InternalSprite(parent::JulGame.IEntity, imagePath::String, crop::Union{Ptr{Nothing}, Math.Vector4}=C_NULL, isFlipped::Bool=false, color::NTuple{4, Int} = (255,255,255,255), isCreatedInEditor::Bool=false; pixelsPerUnit::Int=0, position::Math.Vector2f = Math.Vector2f(0,0), rotation::Float64 = 0.0, layer::Int = 0, center::Math.Vector2f = Math.Vector2f(0.5,0.5), anchor::Symbol = :center, offset::Math.Vector2f = Math.Vector2f(0,0), isStatic::Bool = false)
50+
function InternalSprite(
51+
parent::JulGame.IEntity,
52+
imagePath::String,
53+
crop::Union{Ptr{Nothing}, Math.Vector4}=C_NULL,
54+
isFlipped::Bool=false,
55+
color::NTuple{4, Int} = (255,255,255,255),
56+
isCreatedInEditor::Bool=false;
57+
pixelsPerUnit::Int=0,
58+
position::Math.Vector2f = Math.Vector2f(0,0),
59+
rotation::Float64 = 0.0,
60+
layer::Int = 0,
61+
center::Math.Vector2f = Math.Vector2f(0.5,0.5),
62+
anchor::Symbol = :center,
63+
offset::Math.Vector2f = Math.Vector2f(0,0),
64+
isStatic::Bool = false
65+
)
5166
this = new()
5267

5368
this.offset = offset
@@ -321,7 +336,12 @@ module SpriteModule
321336
error = unsafe_string(SDL2.SDL_GetError())
322337

323338
if !isempty(error) || this.image == C_NULL
324-
@error("Couldn't open image '$imagePath'! SDL Error: ", error)
339+
try
340+
throw(error)
341+
catch e
342+
@error("Error loading image '$imagePath'! SDL Error: ", e)
343+
Base.show_backtrace(stdout, catch_backtrace()) # Backtrace won't be shown if we don't throw the error
344+
end
325345
SDL2.SDL_ClearError()
326346

327347
# Load from byte array

src/engine/SceneManagement/SceneBuilder.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ module SceneBuilderModule
252252
253253
"""
254254
function create_new_entity(this::Scene)
255-
push!(MAIN.scene.entities, Entity("New entity"))
255+
entity = Entity("New entity")
256+
push!(MAIN.scene.entities, entity)
256257
return entity
257258
end
258259

0 commit comments

Comments
 (0)