Announcement

Collapse
No announcement yet.

Scaleform and mouse cursor

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

    #16
    Figured out that they removed Player Owner, invalidating most of the code. Anyone can rewrite one using the new GetPC function ? i tried but failed after many trial and error.

    Comment


      #17
      Originally posted by dpsygnet View Post
      Figured out that they removed Player Owner, invalidating most of the code. Anyone can rewrite one using the new GetPC function ? i tried but failed after many trial and error.
      try this
      Code:
      HudMovie.Init(HudMovie.GetLP());
      not PC! Because function Init(optional LocalPlayer LocPlay) in GFxMoviePlayer class and your init function must be same or you get error

      Comment


        #18
        I did thank you but i still have a lot of errors

        ..\PZOGfxHUD.uc(11) : Error, 'SetFocus': Bad command or expression
        ...\PZOHUD.uc(51) : Error, Bad or missing expression for token: PZOPlayerController, in '='
        ...\PZOHUD.uc(33) : Error, Cannot call 'Super' of final function 'Destroy'
        ...\PZOHUD.uc(12) : Error, Unrecognized member 'PlayerOwner' in class 'PZOGfxHUD'

        Im not sure what am supposed to do, ill mess around but if someone can help me on it that woul be awesome.

        Comment


          #19
          Managed to get no error or warning but the mouse wont show. Do i need to add something in my maine game .uc file ?
          Here are my files, can anyone help me fix the problemes ?

          notes: the flash actionscript is the same as from first page. also I imported the swf in the UDKHUD package as someone suggested that it wont work elsewhere.


          PZOGfxHUD.uc
          Code:
          class PZOGfxHUD extends GFxMoviePlayer;
          
          var int MouseX;
          var int MouseY;
          
          function Init(optional LocalPlayer LocPlay)
          {
          	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'UDKHud.PZOGfxHUDCursor'
          }
          PZOHUD.uc
          Code:
          class PZOHUD extends UDKHUD;
          
          var PZOGfxHUD          HudMovie;
          var class<PZOGfxHUD> HudMovieClass;
          
          simulated function PostBeginPlay()
          {
          	super.PostBeginPlay();
          
          	HudMovie = new HudMovieClass;
          
          	//HudMovie.PlayerOwner = TPZOPlayerController(GetLP());
          	HudMovie.SetTimingMode( TM_Real );
          	HudMovie.SetViewScaleMode( SM_NoScale );
          	HudMovie.SetAlignment( Align_BottomCenter );
          
          	HudMovie.Init(HudMovie.GetLP());
          	//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;
          	}
          
          	Destroy();
          }
          
          function Vector2d GetMouseCoords()
          {
          	local Vector2d mousePos;
          
          	mousePos.X = HudMovie.MouseX;
          	mousePos.Y = HudMovie.MouseY;
          
          	return mousePos;
          }
          
          event PostRender()
          {
          	local Vector2D playerMouse;
          	local PZOPlayerController PZOPlayer;
          
          	//PZOPlayer = PZOPlayerController(GetLP());
          	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'PZOGFxHud'
          }

          Comment


            #20
            I'm not certain whether it will fix your problem, but I had an issue that my mouse cursor would not track the mouse until I had this in my HUD.uc:
            function vector2D GetMouseCoordinates()
            {
            local Vector2d mousePos;

            mousePos.X = HudMovie.GetVariableNumber("_root._xmouse");
            mousePos.Y = HudMovie.GetVariableNumber("_root._ymouse");

            return mousePos;
            }

            Comment


              #21
              Originally posted by dpsygnet View Post
              the flash actionscript is the same as from first page. also I imported the swf in the UDKHUD package as someone suggested that it wont work elsewhere
              AS works fine, just put your .swf file to 'UDK\UDKGame\Flash\NameOfYourHUDPackage\'
              Also all content used in yours swf should be in a folder 'UDK\UDKGame\Flash\NameOfYourHUDPackage\NameOfYour SWF\'

              Comment


                #22
                Originally posted by srv View Post
                AS works fine, just put your .swf file to 'UDK\UDKGame\Flash\NameOfYourHUDPackage\'
                Also all content used in yours swf should be in a folder 'UDK\UDKGame\Flash\NameOfYourHUDPackage\NameOfYour SWF\'
                I will try that thank you, but it still doesn't fix the playerowner problem. I replaced the HudMovie.Init(HudMovie.GetLP()); but it gives me error about all the other line refering to Playerowner. I changed them to GetLP but i still have more and more error.

                Anyone can simply take my code and try to get it to work, and post it here so that everyone can get a functional mouse cursor ?

                Comment


                  #23
                  this works for me:
                  GFx class
                  Code:
                  class GFxWHUD extends GFxMoviePlayer;
                  
                  var int MouseX;
                  var int MouseY;
                  
                  function Initialize()
                  {
                    Start();
                    Advance(0.0f);
                  }
                  
                  function ReceiveMouseCoords(float x, float y)
                  {
                    MouseX = x;
                    MouseY = y;
                  }
                  
                  DefaultProperties
                  {
                    bDisplayWithHudOff=FALSE
                    bEnableGammaCorrection=FALSE
                    MovieInfo=SwfMovie'WUI.HUD'
                  }
                  HUD:
                  Code:
                  var GFxWHUD HudMovie;
                  
                  simulated function PostBeginPlay()
                  {
                  	super.PostBeginPlay();
                  
                          if (HudMovie == None)
                          {
                  	  HudMovie = new class'WGame.GFxWHUD';
                  	  HudMovie.Initialize();
                          }
                          
                          SizeX = 1024;
                  	SizeY = 768;
                  }
                  
                  function vector2D GetMouseCoordinates()
                  {
                          mousePos.X = HudMovie.MouseX;
                  	mousePos.Y = HudMovie.MouseY;
                  
                  	return mousePos;
                  }
                  If it doesn't help, give me your code, I will look, than I can help

                  Comment


                    #24
                    Thank you, nearly worked

                    was getting a error
                    (21) : Error, 'mousePos': Bad command or expression

                    had to add
                    local Vector2d mousePos;
                    above mousepos, no more error now

                    Still cannot see my mouse through


                    My .swf is located in ///\Development\Src\PZO\Flash

                    my gfx class says
                    MovieInfo=SwfMovie'PZO.PZOGfxHUDCursor'

                    and in UDK in my content browser the path of my swf is

                    ..\..\UDKGame\Flash\PZO\PZOGfxHUDCursor.swf

                    is it supposed to be alright ?

                    also i created my flash file as Actionscript 3 , should i select As2 instead ?

                    am kind of lost as to why it is not working.

                    Comment


                      #25
                      Originally posted by dpsygnet View Post
                      Thank you, nearly worked

                      now i get the error
                      (21) : Error, 'mousePos': Bad command or expression


                      on your HUD class are you extending UDKHUD or something else ?
                      That's just because he forgot to declare mousePos at the top of GetMouseCoordinates, just add:

                      Code:
                      local Vector2D mousePos;
                      at the top of GetMouseCoordinates.

                      Originally posted by dpsygnet View Post
                      My .swf is located in ///\Development\Src\PZO\Flash
                      The swf needs to be in UDKGame\Flash\PZO I think, and that's where you should import it from into your package in UDK. That is pretty much how my files are set up and it works fine.

                      srv's code works well, but I do have a different problem with it. Despite having:

                      Code:
                      SizeX = 1024;
                      SizeY = 768;
                      And despite the fact that the resolution of the window is indeed 1024x768, the coordinates I get from the ReceiveMouseCoords function are in the range of 800x600 (which is what the flash movie is authored in).

                      This breaks things like DeProject, although I can work around it by scaling the coordinates like so:

                      Code:
                      mousePos.X = HudMovie.MouseX / 799.0f * Canvas.ClipX;
                      mousePos.Y = HudMovie.MouseY / 599.0f * Canvas.ClipY;
                      Where Canvas.ClipX is 1024 and Canvas.ClipY is 768.

                      Anyway, like I said I can work around it, but I was wondering if there's a way to get the coordinates out of flash in the resolution of the game, not the flash movie, since it seems like this would be a pain when supporting mutliple resolutions.

                      Comment


                        #26
                        I double checked and my .swf is actually in UDKGame\Flash\PZO

                        I redid my flash as actionscrupt 2 but it still wont work. It's frustrating, i have no error , the problem could be anywhere and everything !

                        anything special in the way you create your cursor ?
                        are you changing the resolution of the scene ?
                        I created a movie clip and imported a .tga, added it to the librarym, added the tga into the movie clip, selected the first frame of the scene, added the actionscript and exported a swf

                        Comment


                          #27
                          We just have a movie clip with the cursor image, and in ActionScript on the clip we have added:
                          Code:
                          onClipEvent (mouseMove)
                          {
                             _x = _x + _xmouse;
                             _y = _y + _ymouse;
                          }
                          This should make the cursor show up when previewed in Flash as well, it's from the examples of how to get a cursor to work (in flash).

                          Comment


                            #28
                            tryed to replace my flash code with yours and it didn't works

                            Do you have anything related to your mouse in your playercontroller, pawn, main classes ?

                            I did a quick kismet to play my swf cursor just in case it was a stupid error of it being invisible and i can see it, but it's not moving..

                            Comment


                              #29
                              Nope, nothing like that, it works for us when previewed in Flash as well....

                              Comment


                                #30
                                also i created my flash file as Actionscript 3 , should i select As2 instead ?
                                only AS2 ! AS3 not supported for now as i know

                                I have created flash HUD the same size as a standard window of start UDK - 1024х768 (these sizes I have applied for SizeX/Y)
                                dpsygnet, your swf file should is on this path: '.\.\UDKGame\Flash\PZO\'
                                and content is:
                                '.\.\UDKGame\Flash\PZO\PZOGfxHUDCursor\'
                                If all is alright, also yours .png (only PNG, not TGA) file of the cursor with the correct identifier it should be imported itself to library at import swf.
                                After all it problems with my code shouldn't be.
                                I think that your problem in an incorrect content path and file extension (should be .png).

                                lordshtzu, while coordinates in uc are transferred from AS these coordinates will be only concerning the sizes of working area swf

                                and for Action Script this is my mouse listener and mouse drag code:
                                Code:
                                import flash.external.ExternalInterface;
                                
                                Mouse.hide();
                                
                                var mouseMoveListener:Object = new Object();
                                
                                mouseMoveListener.onMouseMove = function()
                                {
                                	ExternalInterface.call("ReceiveMouseCoords", _root._xmouse, _root._ymouse);
                                	updateAfterEvent();
                                };
                                
                                Mouse.addListener(mouseMoveListener);
                                startDrag("cursor_mc", true);
                                cursor_mc is instance of my cursor movie clip located manually in frame

                                sorry for my English

                                Comment

                                Working...
                                X