Jump to content

click burst example and emmiter gravity


RalphWiggum
 Share

Recommended Posts

So I'm brand new to Phaser 

I decided to try the click burst example as a tutorial http://phaser.io/examples/v2/particles/click-burst

I'm on MS Windows  I have the latest Chrome browser.

I download phaser.js and phaser.min.js from here http://phaser.io/download/stable (this is the 2.7.6 version)

I downloaded the  Mongoose web server as recommended here http://phaser.io/tutorials/getting-started/part2 

I copied the code from the click burst example and put it inside a web page named index.html  https://pastebin.com/P4dDtXSK 

I started Mongoose and navigated to index.html (which is local on my D: drive)

The page opened. I could see color and if I clicked on the page a diamond showed up. Then another diamond, and another and another... 

But, the diamonds weren't being a "fountain" of diamonds. They were showing up directly under each other and not moving.

Every time I clicked I got a new emitter in the clicked position, but the diamonds weren't moving.  

I did a google search for relevant terms and only found the mention of emitter explode being better than emitter start.

Finally found the API https://photonstorm.github.io/phaser-ce/Phaser.Particles.Arcade.Emitter.html#gravity  and saw that gravity is a Phaser point.

Which led me to line 121 of  emitter.js   https://photonstorm.github.io/phaser-ce/src_particles_arcade_Emitter.js.html#sunlight-1-line-121 

The example set gravity with 
emitter.gravity = 200; 

but line 121 sets gravity with 
this.gravity = new Phaser.Point(0, 100);

The line in the example does not look like a point to me (its only one number). So I changed the code in my html file to set gravity the same way line 121 does (by making a new point and assigning it to gravity). 
emitter.gravity = new Phaser.Point(0, 100);

I reloaded my web page in mongoose and now the emitter works as expected. 

So...
what am I missing ? What am I not understanding ? 

Is the example incorrect ? Why does the example work on the phaser website, but now on my computer ? 
Is there some really stupid mistake in my code ? 
Is 
emitter.gravity = 100;  
a shortcut for 
emitter.gravity = new Phaser.Point(0, 100); 

Oh, I'm also a total noob to javascript.
I'm an expert in MS Excel and VBA and beginner / intermediate in R so I know some programming.

Thanks for the help

 

Link to comment
Share on other sites

Emitter#gravity changed to a Phaser.Point in Phaser CE 2.7.2. Unfortunately that change wasn't backwards-compatible so it's been confusing.

The particle examples are written for Phaser <= 2.6.2 when gravity was a number.

With Phaser >= 2.7.2 you can use

emitter.gravity.y = 100;

or

emitter.gravity.setTo(0, 100);

or `new Phaser.Point` like yours. 

Link to comment
Share on other sites

thanks 

that explains a lot 

is there a place where all these changes are listed 

I see this page https://photonstorm.github.io/phaser-ce/#change-log 

and read the Change Log there 
but it it only has the most recent changes --- so the gravity change isn't mentioned 

It does have this line 
For changes in previous releases please see the extensive Version History

But the link leads me to a 404 page 
https://photonstorm.github.io/phaser-ce/CHANGELOG.md

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...