How to remove an image?

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
nerfman7
Prole
Posts: 1
Joined: Sun Aug 09, 2015 6:23 am

How to remove an image?

Post by nerfman7 »

So I need to remove an image and a song using an if statement. If gamestate = play then (Remove image,song)

Code: Select all

    gamestate = "title"

    function love.update(dt)
		   mainmenu = love.graphics.newImage("back.jpg")
		   playbackground = love.graphics.newImage("playbackground.png")
music = love.audio.newSource( 'background.mp3', 'stream' )
music:setLooping( true ) --so it doesnt stop
music:play()
      if gamestate == "title" then
        if love.keyboard.isDown("return", "enter") then
          gamestate = "play"
        end
      else
        -- do your game logic here
	  end
      end
    end

    function love.draw()
	love.graphics.draw(mainmenu)
      if gamestate == "title" then
        love.graphics.print( "Press Enter To Play")
      else
        -- draw your game here
      end
    end
    end

Please Help :)
User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: How to remove an image?

Post by arampl »

User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to remove an image?

Post by zorg »

First, please check out the wiki if you haven't yet, since it will tell you, if you look up all those love._.new_ functions, that you should not use them in love.update, since it will run every frame.

Use love.load to load assets only once at the beginning of the game;
and also use the local keyword to not pollute the global namespace with variables.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

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