Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

CBEffects : Rotate vent to match object rotation
Started by Appletreeman May 25 2016 08:30 AM

4 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 420 posts
  • Corona SDK

Hi, I'm just getting started with CBE and I'm liking it so far.  In my current project I have a player ship that can be rotated through 360 degrees, and I'd like an emitter a vent to rotate with it for an exhaust effect.

Looking through the docs I can't see anything obvious that would enable me to do this.  Is it possible, and if so how?

 

Many thanks.



[TOPIC: post.html]
#2

torbenratzlaff

[GLOBAL: userInfoPane.html]
torbenratzlaff
  • Contributor

  • 404 posts
  • Corona SDK

An emitter object has the "angle" property, as stated in the docs.

https://docs.coronalabs.com/api/type/EmitterObject/index.html

 

Mabye you could ajust it to your needs?



[TOPIC: post.html]
#3

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 420 posts
  • Corona SDK

Cheers for that Torben, but I'm wanting to use CBEffects rather than Corona's particle system.

Anyone else have an idea?



[TOPIC: post.html]
#4

redninjacat

[GLOBAL: userInfoPane.html]
redninjacat
  • Contributor

  • 196 posts
  • Corona SDK

Below is some sample code that uses a timer to change the angle of the laser, both the velocity and the rotation of the individual particles. Hopefully, this points you in the right direction.

local angle = 0
timer.performWithDelay(100, function()
		angle = angle - 5
	end, -1)

local angles = CBE.newVent({
	title = "angles",
	preset = "lasergun",
	onCreation = function(particle, vent)
		particle:setVelocity(10 * math.cos(angle*(math.pi/180)), 10 * math.sin(angle*(math.pi/180)))
		particle.rotation = angle
	end,
})

angles:start()


[TOPIC: post.html]
#5

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Hi and sorry for not seeing this sooner.

 

This is built into CBE:

vent.angles = {10, 15, 20}
vent:resetAngles() -- Use this to make the vent recalculate particle trajectories

- Caleb




[topic_controls]
[/topic_controls]