Working Only In Parts of the Screen?

  • So, a very nice person wrote this for me a while ago:

    The only problem is is it works only in one section of the screen. The screen size itself is 1024x768. But the object only interacts with the rest of the game within the first 640x480.

    Any ideas how to get it to react with the rest of the screen?

    What I'm doing is trying to make a minimal rts. This is how the object is created:

              public var LoopSelect:SelectionBox;
                LoopSelect = new SelectionBox();
    	LoopSelect.scrollFactor.x = LoopSelect.scrollFactor.y = 0;


            for (unit in PlayerScoutGroup.members)
    		if (unit.overlaps( )
    				unit.Selected = true;
    			unit.color = 0xFF0000;
    		if (FlxG.mouse.justReleasedRight && unit.Selected == true) 
    			unit.Selected = false;
    			FlxVelocity.moveTowardsObject(unit, mouseCon, zombieSpeed);
    			unit.color = 0x0000FF;

    Still on 3.55.

  • @xhunterko said in Working Only In Parts of the Screen?:


    I can't see the exact problem. Most likely a mismatch between mouse.screenX/Y and scrollfactors. Can I see SelectionBox()?

  • It's here in the pastebin:

  • Oh, silly me, actually checked that one, didn't notice it was the function I mentioned.

    You mean, that you cannot draw the selection box higher than 640x480, or that doesn't actually select your game objects? Are your objects using screen space or world space? Are those UI elements, or entities that move in a world?

    I'm more positive about a mismatch on that. Could you do a .gif to show the problem?

  • Sure. It's a bit long.

    See it draws across the screen fine. But it's interaction is limited. I added the scrollfactor to see if that'd help at all. I am not sure it did.

    The camera world size itself is 1024x768. The screen(window) size is 640x480.

  • You should probably replace FlxG.mouse.screenX/Y with just FlxG.mouse.x/y – screenX is the position of the mouse pointer in the game window, rather than in the world. Ah, and you'll want to keep scrollFactor at the default (1,1), since you want the selection box to be relative to the camera position ;)

  • Well.

    That occurs when the scrollfactor is 0, 1, or -1. I have been thinking. Right now I am going:

     public var mouseCon:FlxSprite
     //Have mouseCon "glued" to the mouse

    Then I am using the mouseCon as a mouse cursor.

    But, I've been thinking of instead, putting the mouseCon, in a class. Then I would do:

     class mouseCon extends FlxSprite
     //Glue the mouseCon to the mouse the same way 

    Then, in selection box, instead of:

     startPos.x = FlxG.mouse.x;
     startPos.y = FlxG.mouse.y;
     endPos.x = FlxG.mouse.x;
     endPos.y = FlxG.mouse.y;			
     //endPos.y = FlxG.mouse.screenY;	

    It would be:

     Public Var Mouse:MouseCon
     startPos.x = Mouse.x;
     startPos.y = Mouse.y;
     endPos.x = Mouse.x;
     endPos.y = Mouse.y;			
     //endPos.y = FlxG.mouse.screenY;	

    Or would that not make a difference?

  • I don't think your idea will work, but hey, it's worth a try.
    Also, I noticed that the SelectionBox class resets scrollFactor to 0 every tick in its update() method... So if you haven't changed it in there, that's worth a try too.

    (oh, and a possibly stupid question: What exactly is the you check for overlaps with? It doesn't seem to ever be assigned a value :confused:)

  • Ah, it did something for the original as3 flixel version:

    But now it does nothing. And nuts, thought it'd fix something.

    Yes, I did remove that scrollfactor in the update. I thought since in the create wasn't working as thought, I might need to put it in the update.

Log in to reply

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