Camera

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.
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Camera

Post by yetneverdone »

Okay, theres alot of problem, first of all, i suggest that you put proper indentation in the codes inside the function block, put spaces after each "end" in function. Second, as ive pointed out before, put all your global require in the main.lua file, because youre requiring the same module in many files which is inconvenient.

Anyways, i dont see any errors. Whats the problem?
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Camera

Post by yetneverdone »

KyleFlores1014 wrote: Sat Jun 03, 2017 9:43 am game.love here is the code i already wrote the switch function but it still makes an error because of the font when you click about

It's because of your switch function. Instead of using the

Code: Select all

state:exit()
state:load()
use

Code: Select all

state.exit()
state.load()
There's a difference between the : and . syntax

AND ALSO, youre not using the switch function. You dont put a function in your game and then just let it there without actually using/calling it. Instead of using your old method of just saying

Code: Select all

state = newState
do

Code: Select all

switchState(newState)
Oh, and also, instead of hardcoding the coordinates/position of the gui you want to check if pressed, make a table that contains their position.
Example

Code: Select all

startButton = {
	img = "img",
	x = 120,
	y = 120,
	width = 32,
	height = 32
}

--in checking
if mouseX > startButton.x and mouseX < startButton.x + startButton.w then
	--rest of code
end

--drawing them
love.graphics.draw(startButton.img,startButton.x,startButton.y)

oh, another, there's no "id" argument for the mousepressed/mousereleased function

Oh, here you go. I've fixed your gamestate switching.There's still some errors because of the way you hardcoded the checking in mouse functions.
new.zip
(506.2 KiB) Downloaded 105 times
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Camera

Post by KyleFlores1014 »

Oh sorry about the mousepressed it was button not id
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Camera

Post by yetneverdone »

KyleFlores1014 wrote: Sat Jun 03, 2017 10:10 am Oh sorry about the mousepressed it was button not id
It's (x,y,button,istouch) dont forget
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Camera

Post by KyleFlores1014 »

game.love
(505.52 KiB) Downloaded 210 times
here is my new code but the mouse function ruined it and the mouse function no longer works but im trying to fix it
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Camera

Post by yetneverdone »

KyleFlores1014 wrote: Sat Jun 03, 2017 1:42 pm game.love here is my new code but the mouse function ruined it and the mouse function no longer works but im trying to fix it
Yes, when i fixed your mousepressed function, your code doesn't work the way it supposed to because of your hardcoded value, as ive pointed in the post above.
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Camera

Post by KyleFlores1014 »

So how do i fix it I mean I can rewrite it again
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Camera

Post by yetneverdone »

KyleFlores1014 wrote: Sat Jun 03, 2017 2:04 pm So how do i fix it I mean I can rewrite it again
Yes, rewrite it again. Make variables for your "text" positions, and use that variable for checking if mouse was pressed inside thar button box. See my post above for clarification
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Camera

Post by KyleFlores1014 »

Oh ok thanks
KyleFlores1014
Citizen
Posts: 73
Joined: Thu May 25, 2017 1:43 pm

Re: Camera

Post by KyleFlores1014 »

So im beginning to rewrite my code but i still get the same error i dont know whats wrong with my code
game.love
(117.93 KiB) Downloaded 193 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests