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

  • SEARCH
  • Home
  • 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 9197959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:11:05+00:00 2026-06-17T22:11:05+00:00

Hi stackoverflow community I’m trying to layer images by using KineticJS. Unfortunatly it does

  • 0

Hi stackoverflow community

I’m trying to layer images by using KineticJS. Unfortunatly it does not work.
Like you see in the code snippet i’m setting the Z-Index of two pictures, when i log them they’re still in the same order.
You can see the function startClouds(field). This function creates clouds with a Z-Index of 2, what actually works. Im trying to fix that since an hour and i really have no idea why its not working.

var title = new Image();
var title_p = new Image();
title.src = '/test/images/title_bg.png';
title_p.src = '/test/images/title_pic.png';

title.onload = function(){
    var title_background = new Kinetic.Image({
        x: 0,
        y: 0,
        image: title
    });
    field.add(title_background);
    title_background.setZIndex(1);
    field.draw();
    console.log('Z-Index of background: '+title_background.getZIndex());

    var title_pic = new Kinetic.Image({
        x: 0,
        y: 0,
        image: title_p
    });
    field.add(title_pic);
    title_pic.setZIndex(3);
    field.draw();
    console.log('Z-Index of Title: '+title_pic.getZIndex());

    startClouds(field);

    var start = new Kinetic.Text({
        x: 240,
        y: 160,
        text: '[Press Any Key to Start]',
        fontSize: 22,
        fontFamily: 'Calibri',
        fill: 'white'
    });
    field.add(start);
    field.draw();
    stage.add(field);
}

Thx for the help straight ahead

  • 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-17T22:11:06+00:00Added an answer on June 17, 2026 at 10:11 pm

    In kineticjs every time you add a new image to a layer, the index is automatically set. Indexes start at 0

    First, re-order your code like so:

     //create objects first
     var title_background = new Kinetic.Image({
        x: 0,
        y: 0,
        image: title
     });
     var title_pic = new Kinetic.Image({
        x: 0,
        y: 0,
        image: title_p
     });
     var start = new Kinetic.Text({
        x: 240,
        y: 160,
        text: '[Press Any Key to Start]',
        fontSize: 22,
        fontFamily: 'Calibri',
        fill: 'white'
    });
    // now add objects to layer
    field.add(title_background);   // z-index of 0
    field.add(title_pic);          // z-index of 1
    field.add(start);              // z-index of 2
    
    startClouds(field);   // anything created by startClouds() is going to have z-index > 2
    

    if you want to move things around z-indexes, try to avoid

     .setZIndex()  //note: use this AFTER all the objects have been added to the layer
    

    function and use

     .moveToTop() and .moveToBottom() //this way the movement is relative rather than specific.
    

    If you’d like more help, paste some functional code in a jsfiddle and I can help you out some more.

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

Sidebar

Related Questions

Hello stackoverflow community ! I am trying to figure out how to architect my
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
Dear members of the Stackoverflow community, We are developing a web application using the
I want to say hello to the stackoverflow community. I've just started using knockout
Hello stackoverflow community. I do not want to draw each pictureBoxes image to Panel1
I would like to get the stackoverflow community's opinion on the following three design
Hello stackoverflow community, I have a rather simple piece of code that is getting
Hi stackoverflow community, I'm using Android API 14 on a droid 4.0.3 device. In
Hi stackoverflow community, i'm using RKObjectManager to make iOS RESTful requests to map responses
Hi Stackoverflow community, I am working on some code where a list of optional

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.