[SOLVED]image destroy doesn't work

Return to Code Snippets

[SOLVED]image destroy doesn't work

Postby ppanda » Sat Nov 26, 2011 10:54 pm

Why the following doesn't work?

I'm getting an error: global name 'np' is not defined.

Code: Select all
class BttnPrss(DirectObject):
   def __init__(self):
      self.accept("p",self.addbg)
      self.accept("o",self.rembg)
   def addbg(self):
      np=OnscreenImage('image.jpg')
      np.setPos(0, 1, 0.8)
       return np
   def rembg(self):
      np.destroy()
      return
Last edited by ppanda on Mon Nov 28, 2011 12:44 pm, edited 1 time in total.
User avatar
ppanda
 
Posts: 25
Joined: Sat Nov 26, 2011 9:16 pm

Postby DangerOnTheRanger » Sat Nov 26, 2011 10:57 pm

Replace "np" with "self.np", and this snippet will work.

EDIT: Post #150! :)
Free + open-source game development kit: http://openblox.sourceforge.net

My blog: http://dangerontheranger.blogspot.com
User avatar
DangerOnTheRanger
 
Posts: 240
Joined: Fri Aug 27, 2010 4:59 pm

Postby ppanda » Sun Nov 27, 2011 4:18 am

Yes, that solves it. Many thanks!
User avatar
ppanda
 
Posts: 25
Joined: Sat Nov 26, 2011 9:16 pm


Return to Code Snippets

Who is online

Users browsing this forum: Google [Bot] and 0 guests