Author Topic: FlxExtendedSprite doesnt receive clicks  (Read 1126 times)

Tal

  • Member
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
FlxExtendedSprite doesnt receive clicks
« on: Sun, Feb 2, 2014 »
Hey I have a new problem:

I have set up a FlxExtendedSprite to receive mouse clicks (enableMouseClicks; mousePressedCallback;) and added the FlxMouseControl plugin. I should be good to go now. But thats where my problem jumps in. When I click the sprites that have the mouseclicks enabled, nothing happens.

Any idea what could have gone wrong?

Gama11

  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Re: FlxExtendedSprite doesnt receive clicks
« Reply #1 on: Sun, Feb 2, 2014 »
Please post the relevant code section.

Tal

  • Member
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: FlxExtendedSprite doesnt receive clicks
« Reply #2 on: Sun, Feb 2, 2014 »
Code: [Select]
package 
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;

/**
* ...
* @author Tal
*/
public class Planet extends FlxExtendedSprite
{
public var
theMass:Number,
radius:Number,
rotationSpeed:Number,
orbitSpeed:Number,
orbitHelper:Number,
theName:FlxText,
clickHelper:FlxExtendedSprite,
toggle:Boolean;

public static const
SMALL:int = 20,
MEDIUM:int = (SMALL + LARGE) / 2,
LARGE:int = 50,
MAXMASS:int = (FlxG.width - LARGE) / 2;

public function Planet(mass:Number, size:Number)
{
super();
makeGraphic(size, size, 0xff445533);

theMass = mass;
radius = size / 2;
rotationSpeed = randomRange(40, 80);
orbitSpeed = randomRange(0.01,0.1);
orbitHelper = Math.random() * 360;

theName = new FlxText(0, 0, 150);
theName.alignment = "center";
GameState.planetNames.add(theName);

enableMouseClicks(false);
mousePressedCallback = openDialog;
}
        }
}

It seems that as long as i have the FlxExtendedSprite as my Planet class it wont receive clicks. I just tried adding a helper FlxExtendedSprite that floats above my Planet and receives clicks, for some reason it worked. Anyways I would rather have the clicks being received directly by my planet class.

agarciape

  • New Member
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: FlxExtendedSprite doesnt receive clicks
« Reply #3 on: Mon, Apr 11, 2016 »
Did you ever get a reply to this?? I'm having sort of the same issues and was looking for help