Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9002901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:38:06+00:00 2026-06-16T00:38:06+00:00

I am using kineticJS to build a map for a computer game that I

  • 0

I am using kineticJS to build a map for a computer game that I frequently play (X3AP, fwiw).

The map is being built from XML as a series of kinetic image objects. In my first prototype build, I directly added the various images for a sector to the universe layer (that is a black box for each links left, right, up and down, the square for the sector itself, the text for the name, a kinetic image for whether or not it contains a station of note). All of the sectors are drawn to a layer (ending up with a layer that is much bigger than the stage) and that layer is drawn to the stage.

When I implemented dragging on that layer, the drag is laggy.

My first thought was instead of adding these things directly to the layer representing the universe map, add them all to a local variable layer, use that layer’s toImage and in the handling function, add the resulting image to the layer that I use for the map. The image was returning blank (checked with Firefox’s firebug).

I figured this might be down to never having drawn the local layer to the stage at any point, so there’s nothing to be imagified so I tried drawing the entire layer as I was and running a toImage on that, but this time I got a smaller image than what I was expecting (something akin to this http://jsfiddle.net/3tUj7/5/).

I can clone the map layer and add it to a second canvas object which has its properties set to the real size, to get the entire image. Is this the appropriate way?

var layer;
$(
    function()
    {
        var stage = new Kinetic.Stage({
            width:100,
            height:100,
            container:'canvas'
        });
        layer = new Kinetic.Layer({
            width:200,
            height:200,
            draggable:true
        });
        stage.add(layer);

        layer.add(
            new Kinetic.Rect({
                fill:'black',
                x:0,
                y:0,
                width:200,
                height:200
            })
        );

        for(var i = 0; i < 100; i++)
        {
            var x = parseInt(Math.random()*190);
            var y = parseInt(Math.random()*190);
            layer.add(
                new Kinetic.Rect({
                    x:x,
                    y:y,
                    width:10,
                    height:10,
                    fill:'red',
                    stroke:'black',
                    strokeWidth:1
                })
            );
        }
        layer.draw();
        // only returns the image of the *shown* part of the layer
        layer.toImage({
            callback:function(img)
            {
                $('#canvasImg').attr('src', img.src);
            }
        });
    }
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:38:07+00:00Added an answer on June 16, 2026 at 12:38 am

    I ended up using a group, rather than a layer, adding the group at position 0,0 and a width and height of 110. All items were added to that group as though it were placed where it needed to be for the tile to be in the correct place (so between 0 and approximately 110).

    The toImage worked on that group as expected allowing me to avoid the generation of an image the size of the layer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a little game, using KineticJS. For the animation of the character movement,
Using KineticJS, i've been trying to create a group that has just a circle
I'm trying to build a web app using KineticJS, I basically have a function
I'm trying to animate an image using KineticJS to move across the screen, but
Hey I am implementing the drag and drop operations using Kineticjs Now I want
I'm tasked with building an app that would recreate an image using words and
I'm trying to figure out why creating a canvas using KineticJS isn't working on
I am using the latest kineticjs.(v.3.10) Here is the problem I am using a
Using the following as an example (with $db being a previously created database connection
I want to show only intersection of two shape by using KineticJS . How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.