Problem with enabling sprite (SOLVED)

So I’m trying to enable a sprite using a mouse input however this does not work. I’m using

msg.post("#sprite", "disable", {id = hash("sprite")}) 

in the init function to disable the sprite when the program starts and

msg.post("#sprite", "enable", {id = hash("sprite")}) 

to enable the spirte when a mouse input is detected

This is the full code I’m using to do this. The sprite is successfully disabled when the program loads up but does not enable through the mouse input.

function init(self)
	msg.post('.', 'aquire_input_focus')
	msg.post("#sprite", "disable", {id = hash("sprite")})
end

function on_input(self, action_id, action)
	if action_id == hash("rightclick") and action.pressed then
		msg.post("#sprite", "enable", {id = hash("sprite")})
	end
end

That’s what I did.

function init(self)
	msg.post(".", "acquire_input_focus")
	msg.post("#sprite", "disable")
end

function on_input(self, action_id, action)
	if action_id == hash("touch") and action.pressed then
		msg.post("#sprite", "enable")
	end
end

Perhaps you have the wrong “action_id”.

Thank you for your response but this does not help. I’m still getting the same issue. No error messages, besides I know that has to be a valid action_id because I’ve used it elsewhere in my program

Maybe you are missing the letter “c”?

2 Likes

I am a complete idiot… thanks

4 Likes