I have a problem stage resize..

Software: Away3D 2.x

joeykim0608, Newbie
Posted: 24 March 2016 07:03 AM   Total Posts: 1

The object view area is cut off if they come out properly reduced by dragging the window.
Obtain advice should be resolved in any way

 

   

cyberix3d, Jr. Member
Posted: 24 March 2016 08:37 AM   Total Posts: 34   [ # 1 ]

You have to keep the aspect ratio to solve the problem.
Here is my resize function for example. You can change and use it for your needs.

private function SetSize(width:Number, height:Number, pos:Point, keepAspectRato:Boolean = true, fixedWidth:Number = 1280):void
{
 
var aspectRatio:Number;     
 var 
starlingHeight:Number;
 var 
starlingWidth:Number;     
 var 
containerHeight:Number;
 var 
containerWidth:Number;
 var 
delta:Number;
 
 
aspectRatio = 9.0/16.0;
 
 if (
keepAspectRato)
 
{
  starlingWidth 
= fixedWidth;
  
starlingHeight = starlingWidth*aspectRatio;  
  
containerWidth = width; 
  
containerHeight = containerWidth*aspectRatio;
  
  if (
containerHeight > height)
  
{
   delta 
= height/containerHeight;
   
starlingHeight *= delta;
   
starlingWidth *= delta;
   
containerHeight *= delta;
   
containerWidth *= delta;
  
}
  
  
  starlingHeight 
= Math.round(starlingHeight);
  
starlingWidth = Math.round(starlingWidth);
  
containerHeight = Math.round(containerHeight);
  
containerWidth = Math.round(containerWidth);
 
}
 
else
 
{
  starlingWidth 
= Math.round(fixedWidth);
  
starlingHeight = Math.round(starlingWidth*aspectRatio);  
  
containerWidth = Math.round(width); 
  
containerHeight = Math.round(height);    
 
}
 
 starlingBackLayers
.Resize(starlingWidth, starlingHeight);
 
starlingFrontLayers.Resize(starlingWidth, starlingHeight);
 
view.x = Math.round((width-containerWidth)/2);
 
view.y = Math.round((height-containerHeight)/2);
 
view.height = containerHeight;
 
view.width = containerWidth;     
 
stage3DProxy.x = Math.round(pos.x+(width-containerWidth)/2);
 
stage3DProxy.y = Math.round(pos.y+(height-containerHeight)/2);
 
stage3DProxy.height = containerHeight;
 
stage3DProxy.width = containerWidth;  
} 

 

   

rustyk, Newbie
Posted: 29 March 2016 02:03 AM   Total Posts: 22   [ # 2 ]

I have a simple resize function but this is quite nice and interesting to check out, thanks for sharing cyberix3d.

 

   

cyberix3d, Jr. Member
Posted: 29 March 2016 05:57 PM   Total Posts: 34   [ # 3 ]

The idea behind this Resize function is to keep the aspect ratio while resizing your game.
If the window width is bigger than the window height you should see black strips on the left and right sides.
If the window height is bigger than the window width you should see black strips on the upper and lower sides.
That way your image won’t be cut.
See the attached pictures for better understanding what the Resize function should do.
If the function I gave you is not working, try to implement what I described.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X