Possible error on compile project (SOLVED)

Hello Guys!
Sometimes when my game project it is compiled Defold does not shows all GameObject attached at main collection.

I built a GIF to show this behavior to you, see below:
If anyone need more information please let me know.

One common issue is that two objects have the same z-value in their position, thus getting “z fighting”. What are the z values for your background and ball?
Does the script do anything else special?

1 Like

humm “z fighting” Does means the order of the object inside of canvas? is it similar the z-index property of css?

Here is the values of background and ball game object:

Here is my script:

local WorldWidth = tonumber(sys.get_config("display.width"))
local WorldHeigth = tonumber(sys.get_config("display.height"))

function init(self)
    msg.post(".", "acquire_input_focus")
    self.speed = 360
    self.angle = 360
    self.myWidth  = 128
 	self.myHeight = 128

end

local function atRightEdge(self)
	local p = go.get_position()
	local worldRightLimit = WorldWidth -  self.myWidth/2
	if p.x >= worldRightLimit then 
		return true
	end
	return false
end

local function atLeftEdge(self)
	local p = go.get_position()
	local worldLeftLimit = self.myWidth/2
	if p.x <= worldLeftLimit then 
		return true
	end
	return false
end

local function atTopEdge(self)
	local p = go.get_position()
	local worldTopLimit = WorldHeigth -self.myHeight/2
	if p.y >= worldTopLimit then 
		return true
	end
	return false
end

local function atBotEdge(self)
	local p = go.get_position()
	local worldTopLimit = self.myHeight/2
	if p.y <= worldTopLimit then 
		return true
	end
	return false
end

local function changeDirection(self)
	if atRightEdge(self) or atLeftEdge(self)  then 
    	self.speed = self.speed * -1
    	
    end
    if atTopEdge(self) or atBotEdge(self) then
    	self.angle = self.angle * -1
    end
end 

local function move(self,dt)
	local p = go.get_position()
    p.x = p.x + self.speed * dt
    p.y = p.y + self.angle * dt
    
    go.set_position(p)
    
end

function update(self, dt)
    move(self, dt)
    changeDirection(self)
end

I tried to change the Ball z-value to ‘1’ and looks like the problems was solved.

Really thanks for your hint and your time.

Just as @Mathias_Westerdahl wrote and as you can see from the values in your screenshots both the ball and the background game object and sprite have z-values of 0. This means that the ball will sometimes be rendered behind the background.

And you figured out the solution yourself, you changed z-value of the ball to 1. Important note: The default range of z-values in the render script (builtins/render/default.render_script) is in the range of -1 to 1. You can use fractional z-values, so you could just as well have set the ball to 0.1 as 1.

Thank you for this great hint! So… this is not a compile error. how can I set this question for solved?

I’ve updated the topic for you.