bbyford

on events not working on sprite

Recommended Posts

I'm adding a sprite in a loop, set interactive and then adding it to a container then the stage but my on events dont seem to be working, any reason why this might be happening?

let map_asset_keys = Object.keys(map_assets_json);

let length = map_asset_keys.length;
let map_assets_arr = []

for (var key in map_assets_json){

  let asset = new Sprite(Resources[key].texture);
  asset.x = map_assets_json[key].coords.x;
  asset.y = map_assets_json[key].coords.y;
  asset.zIndex = length;
  asset.setInteractive = true;
  asset.cursor = 'pointer';

  asset.on('pointerdown', function(){alert()})
  asset.tint = 0x550000;

  map_assets_arr.push(asset);

  --length;
}

let map_group = Groups.group(map_assets_arr);
map_group.x = 0;
map_group.y = 0;
map_group.scale = new PIXI.Point(map_assets_scale * pixel_scale, map_assets_scale * pixel_scale);
map_group.setInteractive = true;
        
app.stage.addChild(map_group);

 

Edited by bbyford

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.