Group And Touch Controls?



  • I have a Block class, which is a FlxSprite, that is spawned as a group of two or more. In windows builds, I can control these easily with FlxG.keys and I can move them around on the screen. I am using the touch control system found here:

    https://github.com/bluroman/Frogger

    So that when I want to control a single class FlxSprite variable, say player extends FlxSprite. I can go into the code and go:

            genericActor = new BlockActor(336, 0, 5);		
    	add(genericActor);	
    	//FallingBlocks.add(genericActor);	
    	genericActor.touchControls = touchControls;
    

    The above is how the Frogger system works. I can attach the controls to a single sprite. So I figured I can attach the controls to all the sprites in a group of sprites, like below:

    	touchControls = new TouchControls(this, calculateRow(1), 376, 16);
    	FallingBlocks.forEach(function(actorB:Block)
    	{
    		actorB.touchControls = touchControls;
    		
    	});
    

    Or like:

    for (actorB in FallingBlocks)
    	{
    		
    		actorB.touchControls = touchControls;
    	}
        add(touchControls);
    

    When the player doesn't touch any controls, the blocks move down by gravity by themselves. This worked in the windows builds. But never in the android builds. Then I added the touch controls, and the blocks began to fall, but I couldn't control them.

    Is there a way to control a group of sprites with touch controls like this?

    I've not tried the mode virtual pad style yet but that's next.



  • Never mind. I got something to work.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.