Testing on android issue [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
test
Prole
Posts: 28
Joined: Sun Apr 14, 2019 2:36 pm

Testing on android issue [SOLVED]

Post by test »

When I test it on a PC it works, but on android the squares are not visible.

Code: Select all

local w, h
local p = {}
for i = 1, 2 do
	p[i] = {}
end
function love.load()
	w, h = love.graphics.getDimensions()
	for i = 1, 2 do
		p[i].element = i
		p[i].x, p[i].y = (2 * i - 1) * w / 4, h / 2
		p[i].w, p[i].h = 100, 100
		p[i].xx, p[i].yy = p[i].x, p[i].y
		p[i].v = 750
	end
end
function love.update(dt)
	local touches = love.touch.getTouches()
	for i, id in ipairs(touches) do
		local x, y = love.touch.getPosition(id)
		for i = 1, 2 do
			if (3 - 2 * i) * x < (3 - 2 * i) * w / 2 and (3 - 2 * i) * x > 200 - (i - 1) * w then
				p[i].xx = x
				p[i].yy = y
			end
		end
	end
	for i = 1, 2 do
		local d = ((p[i].xx - p[i].x) ^ 2 + (p[i].yy - p[i].y) ^ 2) ^ 0.5
		if d > p[i].v * dt then
			p[i].x = p[i].x + (p[i].xx - p[i].x) / d * p[i].v * dt
			p[i].y = p[i].y + (p[i].yy - p[i].y) / d * p[i].v * dt
		end
	end
end
function love.draw()
	love.graphics.setColor(1, 1, 1)
	love.graphics.line(w / 2, 0, w / 2, h)
	for i = 1, 2 do
		if p[i].element == 1 then
			love.graphics.setColor(0.25, 0.28, 0.8)
		elseif p[i].element == 2 then
			love.graphics.setColor(0.5, 0.5, 0.5)
		elseif p[i].element == 3 then
			love.graphics.setColor(0.93, 0.11, 0.14)
		else
			love.graphics.setColor(0.76, 0.76, 0.76)
		end
		love.graphics.rectangle('fill', p[i].x - p[i].w / 2, p[i].y - p[i].h / 2, p[i].w, p[i].h)
	end
end
function love.keypressed(k)
	if k == 'escape' then
		love.event.quit()
	end
end
Last edited by test on Tue May 07, 2019 7:07 pm, edited 1 time in total.
tahoma
Prole
Posts: 22
Joined: Mon Apr 22, 2019 1:13 am

Re: Testing on android issue

Post by tahoma »

Check which love2d you use on android. If 10.2, then you need to use 0-255 color scheme instead of 0-1. All your squares should almost black in love2d 10.2
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 4 guests