Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particles are not copied when building for Web Desktop #605

Closed
ggarek opened this issue Apr 17, 2016 · 6 comments
Closed

Particles are not copied when building for Web Desktop #605

ggarek opened this issue Apr 17, 2016 · 6 comments
Assignees

Comments

@ggarek
Copy link

ggarek commented Apr 17, 2016

Hello,

I built a small project with Cocos Creator. And when i tried to build it for web desktop i found out that not all assets get copied. I have a .plist and .png under assets/particles, but they are absent in build directory.

When i copy them to the build directory under build/web-desktop/res/raw-assets/particles/ everything works as expected.

@jareguo
Copy link
Contributor

jareguo commented Apr 18, 2016

Thanks ggarek, this is a bug, and I hadn't noticed.

@jareguo jareguo self-assigned this Apr 18, 2016
@jareguo
Copy link
Contributor

jareguo commented Apr 18, 2016

Wait, this is by design, not a bug. Only assets under assets/resources directory will be copied.
Please try:

var url = cc.url.raw("resources/particles/1.plist");
particleSystem.file = url;

@jareguo jareguo closed this as completed Apr 18, 2016
@ggarek
Copy link
Author

ggarek commented Apr 18, 2016

@jareguo I created new project from scratch to check it once again. I think there is a though, let me put some more details about it.

First of all, this thing is not correct

var url = cc.url.raw("resources/particles/1.plist");

because the cc.url.raw adds the relative path prefix to the resources in runtime, so you need only pass a path to a specific resource you need relative to your assets/ folder within Cocos Creator.
So if you have

-- assets
  -- textures
    -- mytexture.png

then to get the correct url to mytexture.png you need to make this call:

var url = cc.url.raw("textures/mytexture.png");

Regarding the bug.

I create a project, add particle resource, then drag the particle file to the scene in Cocos Creator. In this case both files (.plist and .png) are copied to the build directory.

But, when i add a particle to Assets in Cocos Creator, then i create the ParticleSystem in runtime, like this:

start: function () {
        const node = new cc.Node();
        const ps = node.addComponent(cc.ParticleSystem);
        ps.file = cc.url.raw('/particles/fire-parts.plist');
        node.setPosition(200, 200);
        cc.director.getScene().addChild(node);
    },

It works in development mode, but when i build the project, the .plist file is absent in the output directory. The .png file though is copied.

Here is the assets dir listing:

➜  cc-particles-not-copied ls -al assets/particles
total 64
drwxr-xr-x  10 garek  staff   340 Apr 18 13:10 .
drwxr-xr-x  11 garek  staff   374 Apr 18 12:56 ..
-rw-r--r--   1 garek  staff  2463 Apr 18 12:47 fire-parts.plist
-rw-r--r--   1 garek  staff    88 Apr 18 12:47 fire-parts.plist.meta
-rwxr-xr-x   1 garek  staff   622 Apr 18 12:47 fire.png
-rw-r--r--   1 garek  staff   633 Apr 18 12:47 fire.png.meta
-rw-r--r--   1 garek  staff  2872 Apr 18 12:45 meteor-tail.plist
-rw-r--r--   1 garek  staff    88 Apr 18 12:45 meteor-tail.plist.meta
-rw-r--r--   1 garek  staff  1210 Apr 18 12:45 particle2.png
-rw-r--r--   1 garek  staff   636 Apr 18 12:45 particle2.png.meta

And here is the build dir listing:

➜  cc-particles-not-copied ls -al build/web-desktop/res/raw-assets/particles
total 24
drwxr-xr-x  5 garek  staff   170 Apr 18 13:11 .
drwxr-xr-x  4 garek  staff   136 Apr 18 13:11 ..
-rwxr-xr-x  1 garek  staff   622 Apr 18 13:11 fire.png
-rw-r--r--  1 garek  staff  2872 Apr 18 13:11 meteor-tail.plist
-rw-r--r--  1 garek  staff  1210 Apr 18 13:11 particle2.png

As you can see, fire.png file is present, but fire-parts.plist is not.

@jareguo
Copy link
Contributor

jareguo commented Apr 18, 2016

But, when i add a particle to Assets in Cocos Creator, then i create the ParticleSystem in runtime
It works in development mode, but when i build the project, the .plist file is absent in the output directory. The .png file though is copied.

As mentioned above, only assets under assets/resources directory will be copied to the output directory.

@ggarek
Copy link
Author

ggarek commented Apr 18, 2016

Ok, i tried to put the .plist and .png which i use to create ParticleSystem dynamically under assets/resources and it is now copied during the build process. Thanks, now i get what you meant.

Still it seems not very convenient. If i create a node via editor then the resource files are copied to the build directory no matter the path, but if i do it dynamically, then i need to put it under a specific path.
But i guess, it may change through the versions, or there will be a hint so everybody know the name convention.

Anyways, thanks for the explanation!

@jareguo
Copy link
Contributor

jareguo commented Apr 18, 2016

Yes there will be a hint in the future, thanks for the feedback ~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants