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

Creating atlas through code #984

devnewton opened this issue Jan 3, 2020 · 1 comment

Creating atlas through code #984

devnewton opened this issue Jan 3, 2020 · 1 comment


Copy link

@devnewton devnewton commented Jan 3, 2020

I try to figure how to use some spritesheet ( like ).

Is it possible to define the atlas manually? Melonjs documentation only talk about Texture Packer or Shoebox.

I tried this:

        let atlas = {
            "meta": {
                "app": "melonJS",
                "size": {"w": 512, "h": 512},
                "repeat": "no-repeat",
                "image": "sara"
            "frames": [{
                    "filename": "stand",
                    "frame": {"x": 1, "y": 1, "w": 32, "h": 48}

       let texture = new
        this.renderable = new me.Sprite(0, 0, {image: texture});
        this.renderable.addAnimation("stand", [{ name: "stand", delay: Infinity }]);

But it is not detected as an atlas:

string parameters for addAnimation are not allowed for standard spritesheet based Texture


This comment has been minimized.

Copy link

@obiot obiot commented Jan 7, 2020

when creating sprite out of atlas, you should rather use the "createAnimationFromName" helper function :

so you should change the renderable definition to :

this.renderable = texture.createAnimationFromName(["stand"]);
this.renderable.addAnimation("stand", [{ name: "stand", delay: Infinity }]);

(also, be careful, you call setCurrentAnimation on this object instead of the renderable)

this should helpfully work now :P

@obiot obiot closed this Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.