bbyford Posted February 18, 2020 Share Posted February 18, 2020 (edited) 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 February 18, 2020 by bbyford Quote Link to comment Share on other sites More sharing options...
bbyford Posted February 18, 2020 Author Share Posted February 18, 2020 Ok, so i simply can't get anything to register an event after having it previously working fine. Is there something global I might have done that stops these from happening? Quote Link to comment Share on other sites More sharing options...
themoonrat Posted February 18, 2020 Share Posted February 18, 2020 asset.interactive = true; Rather than your setInteractive property bbyford 1 Quote Link to comment Share on other sites More sharing options...
bbyford Posted February 18, 2020 Author Share Posted February 18, 2020 AHHHHHHHHH thank you. I'm such a dick. Sometimes you just hit your head against a problem, and sometimes you've created that problem and can't see it Quote Link to comment Share on other sites More sharing options...
themoonrat Posted February 19, 2020 Share Posted February 19, 2020 Haha np! If there's one thing I've learnt in programming: we're all dicks at one stage or another! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.