How do I make screen shake, move etc?

I use something a littel bit less complex and it works for my needs.

go.property("shake", 0)

function init(self)
	msg.post("#camera", "acquire_camera_focus")
	self.pos = go.get_world_position()
	self.look_at = self.pos
end


function update(self, dt)
	if self.shake > 0 then
		go.set_position(self.pos + vmath.vector3(math.random() * self.shake, math.random() * self.shake, 0))
		self.shake = self.shake * 0.9 - 0.1 
	end
end

function on_message(self, message_id, message, sender)
	if message_id == hash("shake") then
		self.shake = 8
	end
end
6 Likes