Announcement

Collapse
No announcement yet.

Scaleform and mouse cursor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Scaleform and mouse cursor

    Hi,
    I'm new to UDK. I've read that using Scaleform, you can create menus and HUD for a game. Few things I'd like to know:
    1 - Is it possible to display a mouse cursor on screen while in game with scaleform, specially with a game extending from ut classes? The only tutorials I know about that are X9 production tutorials (which doesn't use scaleform and doesn't work for me with classes extending from UT classes - dont know why) and pieces of codes from RTS Framework, which work fine but doesn't use Scaleform.
    2 - Is it possible to get mouse world coordinates (deprojection of 2D mouse cursor coordinates), using the same kind of code as I read in RTS framework or on X9 production site?
    When I say: "is it possible?", I mean: is there a video showing it or a piece of code available on these forums I could learn from?
    Any information much appreciated. Thanks.

    #2
    1- Is possible, you can do it in the same way it is done in any flash application.

    2- Is possible, and the X9 tutorial is a good solution. You can find more about mouse projection in this tutorial http://unrealmindset.wordpress.com/2...se-projecting/

    Comment


      #3
      Thanks a lot. I already saw your blog and thought it was very interesting work but I didn't saw this article. I'll read it.

      Comment


        #4
        This is how my Scaleform mouse works.

        In Flash:

        1. A new movieclip symbol with imported bitmaps as the cursor images.
        2. An instance of this movieclip on the main stage in it's own layer.
        3. Following AS in the first frame of the mouse layer:

        Code:
        import flash.external.ExternalInterface;
        
        // Hide normal "Windows" pointer.
        Mouse.hide();
        
        var mouseListener:Object = new Object();
        
        mouseListener.onMouseMove = function ()
        {
                // Set the cursor instance position to the mouse position.
        	MouseCursorInstance._x = _root._xmouse;
        	MouseCursorInstance._y = _root._ymouse;
        	
                // Tell our UnrealScript about the new mouse coords.
        	ExternalInterface.call( "ReceiveMouseCoords", _root._xmouse, _root._ymouse );
        	
        	updateAfterEvent();
        };
        
        Mouse.addListener(mouseListener);
        In Unrealscript:

        A GFxMoviePlayer class for the HUD movie:

        Code:
        class Tds_GFxHud extends GFxMoviePlayer;
        
        var int MouseX;
        var int MouseY;
        
        function Init( PlayerController PC )
        {
        	Start();
        	Advance(0.0f);
         
        	SetFocus( false, true );
        }
        
        // This is called from Flash.
        function ReceiveMouseCoords( float x, float y )
        {
        	MouseX = x;
        	MouseY = y;
        }
        
        DefaultProperties
        {
        	bDisplayWithHudOff = false
        	bGammaCorrection = false
        	
                // Path to your package/flash file here.
        	MovieInfo = SwfMovie'TrGfx.TrHudMain'
        }
        The HUD class the uses the movie:

        Code:
        class Tds_Hud extends UDKHUD;
        
        var Tds_GFxHud           HudMovie;
        var class<Tds_GFxHud> HudMovieClass;
        
        simulated function PostBeginPlay()
        {
        	super.PostBeginPlay();
        
        	HudMovie = new HudMovieClass;
        
        	HudMovie.PlayerOwner = Tds_PlayerController(PlayerOwner);
        	HudMovie.SetTimingMode( TM_Real );
        	HudMovie.SetViewScaleMode( SM_NoScale );
        	HudMovie.SetAlignment( Align_BottomCenter );
        
        	HudMovie.Init( HudMovie.PlayerOwner );
        
                // When using scaleform these seem to be set to 0?
        	SizeX = 1280.0f;
        	SizeY = 720.0f;
        }
        
        singular event Destroyed()
        {
        	if( HudMovie != none )
        	{
        		HudMovie.Close( true );
        		HudMovie = none;
        	}
        
        	super.Destroy();
        }
        
        function Vector2d GetMouseCoords()
        {
        	local Vector2d mousePos;
        
        	mousePos.X = HudMovie.MouseX;
        	mousePos.Y = HudMovie.MouseY;
        
        	return mousePos;
        }
        
        event PostRender()
        {
        	local Vector2D playerMouse;
        	local Tds_PlayerController tdsPlayer;
        
        	tdsPlayer= Tds_PlayerController(PlayerOwner);
        	playerMouse = GetMouseCoords();
        
        	Canvas.SetDrawColor( 255, 255, 255, 255 );
        
        	Canvas.SetPos( 10.0, 10.0 );
        	Canvas.DrawText( "Mouse: X:" $ playerMouse.X $ ", Y:" $ playerMouse.Y );
        
                 // ** Can do the deproject etc. as shown in tutorials here on the values from GetMouseCoords().
        }
        
        DefaultProperties
        {
        	HudMovieClass = class'Tds_GFxHud'
        }
        A screenshot of the result.

        Comment


          #5
          Great! That's exactly what I'm looking for.
          Which classes do you extend from for your pawn, playercontroller and gameinfo?
          Is it possible for you to deproject cursor coordinates to get world mouse position?

          Comment


            #6
            or you could extend my simple Flash Scaleform Cursor class to suit. I like The methods you used there Kitese for the situation you required. Nice

            Comment


              #7
              Thanks, guys. I'll have a look at all this stuff.

              Comment


                #8
                Unfortunately it doesnt seem like SetFocus is in the september build of udk, what can we use instead?

                Comment


                  #9
                  1. A new movieclip symbol with imported bitmaps as the cursor images.
                  2. An instance of this movieclip on the main stage in it's own layer.
                  Is there any chance that someone can tell us how to do that? Steep by step. I will be grateful!

                  Comment


                    #10
                    Originally posted by zero4 View Post
                    Is there any chance that someone can tell us how to do that? Steep by step. I will be grateful!
                    I also clearly would like that to be explain :s

                    Comment


                      #11
                      Hi,
                      I'm having trouble with the default MovieInfo,
                      I get this error when I compile

                      Z:\UDK\Development\Src\RC\Classes\RCGFxHud.uc(36) : Warning, ObjectProperty GFxUI.GFxMoviePlayer:MovieInfo: unresolved reference to 'SwfMovie'RC.menu''

                      Z:\UDK\Development\Src\RC\Classes\RCGFxHud.uc(36) : Warning, Invalid property value in defaults: MovieInfo = SwfMovie'RC.menu'

                      While I've definitively added my menu.swf and menu.fla in :
                      [game directory]/UDKGame/Flash/RC/

                      I had import swf with command 'udk gfximport RC/menu.swf' with no error.

                      Here is my GFxMoviePlayer Class

                      class RCGFxHud extends GFxMoviePlayer;

                      var int MouseX;
                      var int MouseY;

                      function Init(optional LocalPlayer LocPlay )
                      {
                      LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find( LocPlay);
                      if(LocalPlayerOwnerIndex == INDEX_NONE)
                      {
                      LocalPlayerOwnerIndex = 0;
                      }

                      if( MovieInfo != None )
                      {
                      if( bAutoPlay )
                      {
                      Start();
                      Advance(0.f);
                      SetPriority(1);
                      }
                      }
                      }

                      // This is called from Flash.
                      function ReceiveMouseCoords( float x, float y )
                      {
                      MouseX = x;
                      MouseY = y;
                      }

                      DefaultProperties
                      {
                      bDisplayWithHudOff = false
                      // Path to your package/flash file here.
                      MovieInfo = SwfMovie'RC.menu'
                      }


                      Please if anyone can help, I need a mouse T.T
                      Thanks !

                      Comment


                        #12
                        Ok, I've managed to get rid of warning and error during compilation.
                        And now it work.
                        I had to import my .swf with udk content browser, and move it in the UDKHUD package in order to correctly have the .swf loaded via unrealScript. Why my package didn't work ... don't know -_-
                        Anyway I've got a mouse ! cheers !

                        Comment


                          #13
                          Anyone got it to work with the november release ? i got an error about


                          ...\Classes\PZOGfxHUD.uc(6) : Error, Redefinition of 'function Init' differs from original

                          Comment


                            #14
                            Look at init function of the parent ... it's not the same ! And it must be the same

                            Comment


                              #15
                              I did that previously and got a whole lot more different errors in frontend. Can you post your working code so i can compare ?

                              Comment

                              Working...
                              X