Click counter

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
edwardander
Prole
Posts: 10
Joined: Tue May 20, 2014 10:08 am

Click counter

Post by edwardander »

Hi all,

i am just training on love. i decided to make a little program which is kind a showcase of flux tweening library. in scenario it must change the tweening ease at every click. but unfortunately, i could not change the index of the "easemods" by every single clicking. here is my code, where do i make the mistake?

Code: Select all

flux = require "flux"

function love.load()
player={x = 100, y = 100}     --> start point of the player
easemodes={"linear", "quadin", "quadout", "quadinout", "cubicin",     --> ease modes of the flux lib
  "cubicout", "cubicinout", "quartin", "quartout", "quartinout", 
  "quintin", "quintout", "quintinout", "expoin", "expoout", 
  "expoinout", "sinein", "sineout", "sineinout", "circin", 
  "circout", "circinout", "backin", "backout", "backinout", 
  "elasticin", "elasticout", "elasticinout"}
n=1     --> ease modes indexer. this should be iterated by clicking

end 

function love.update(dt)
	flux.update(dt)
  flux.to(player, 2, {x=love.mouse.getX(),y=love.mouse.getY()}):ease(easemodes[n])      --> the square follows the mouse cursor here. alse ease mode is selected
  if love.mouse.isDown("l") then      --> my wrong code which cant change "n" by clicking. my question about here mostly
    if not love.mouse.isDown("l") then
      n=n+1
    end
  end
  
 
end

  
function love.draw()
  love.graphics.print(easemodes[n],20,20)     --> shows which mode we are at
	love.graphics.setColor(255, 0, 0, 255)	
	love.graphics.rectangle("fill", player.x, player.y, 10, 10)
end

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Click counter

Post by bartbes »

edwardander wrote:

Code: Select all

  if love.mouse.isDown("l") then
    if not love.mouse.isDown("l") then
How would that ever work?

You probably just want to do something like this:

Code: Select all

function love.mousepressed(x, y, button)
    if button == "l" then
        n = n%#easemodes + 1
    end
end
edwardander
Prole
Posts: 10
Joined: Tue May 20, 2014 10:08 am

Re: Click counter

Post by edwardander »

you know, after one moment you try really silly thing. but i can swear that i tried "love.mousepressed" function too. i think i need a coffee

thank you.
Post Reply

Who is online

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