Skip to content

Commit

Permalink
added support for 4x textures
Browse files Browse the repository at this point in the history
fixed bugs with scrollable horizontal containers
  • Loading branch information
prime31 committed Jun 17, 2012
1 parent 8913e98 commit 60be20c
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 84 deletions.
Binary file modified Assets/DemoAssets/Resources/kitchenSinkSheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
126 changes: 63 additions & 63 deletions Assets/DemoAssets/Resources/kitchenSinkSheet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,122 @@

"Gai_1.png":
{
"frame": {"x":136,"y":167,"w":40,"h":52},
"frame": {"x":246,"y":384,"w":48,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":5,"y":4,"w":40,"h":52},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":48,"h":64},
"sourceSize": {"w":48,"h":64}
},
"Gai_10.png":
{
"frame": {"x":177,"y":296,"w":46,"h":54},
"frame": {"x":93,"y":361,"w":56,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":4,"y":6,"w":46,"h":54},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":56,"h":64},
"sourceSize": {"w":56,"h":64}
},
"Gai_11.png":
{
"frame": {"x":177,"y":245,"w":54,"h":50},
"frame": {"x":177,"y":189,"w":64,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":7,"y":5,"w":54,"h":50},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":64,"h":64},
"sourceSize": {"w":64,"h":64}
},
"Gai_12.png":
{
"frame": {"x":37,"y":402,"w":37,"h":56},
"frame": {"x":134,"y":426,"w":55,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":12,"y":3,"w":37,"h":56},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":55,"h":64},
"sourceSize": {"w":55,"h":64}
},
"Gai_2.png":
{
"frame": {"x":75,"y":402,"w":42,"h":52},
"frame": {"x":443,"y":252,"w":64,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":20,"y":3,"w":42,"h":52},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":64,"h":64},
"sourceSize": {"w":64,"h":64}
},
"Gai_3.png":
{
"frame": {"x":157,"y":402,"w":40,"h":50},
"frame": {"x":295,"y":384,"w":46,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":5,"w":40,"h":50},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":46,"h":64},
"sourceSize": {"w":46,"h":64}
},
"Gai_4.png":
{
"frame": {"x":118,"y":402,"w":38,"h":52},
"frame": {"x":206,"y":319,"w":48,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":7,"y":4,"w":38,"h":52},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":48,"h":64},
"sourceSize": {"w":48,"h":64}
},
"Gai_5.png":
{
"frame": {"x":177,"y":351,"w":46,"h":50},
"frame": {"x":177,"y":254,"w":64,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":17,"y":1,"w":46,"h":50},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":64,"h":64},
"sourceSize": {"w":64,"h":64}
},
"Gai_6.png":
{
"frame": {"x":1,"y":75,"w":35,"h":50},
"frame": {"x":190,"y":426,"w":55,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":16,"y":5,"w":35,"h":50},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":55,"h":64},
"sourceSize": {"w":55,"h":64}
},
"Gai_7.png":
{
"frame": {"x":433,"y":248,"w":47,"h":52},
"frame": {"x":150,"y":361,"w":55,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":3,"y":3,"w":47,"h":52},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":55,"h":64},
"sourceSize": {"w":55,"h":64}
},
"Gai_8.png":
{
"frame": {"x":1,"y":189,"w":80,"h":58},
"frame": {"x":37,"y":431,"w":96,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":8,"y":2,"w":80,"h":58},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":96,"h":64},
"sourceSize": {"w":96,"h":64}
},
"Gai_9.png":
{
"frame": {"x":1,"y":126,"w":20,"h":52},
"frame": {"x":1,"y":75,"w":26,"h":64},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":4,"y":9,"w":20,"h":52},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":26,"h":64},
"sourceSize": {"w":26,"h":64}
},
"cbChecked.png":
{
"frame": {"x":165,"y":453,"w":44,"h":44},
"frame": {"x":302,"y":449,"w":48,"h":48},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":2,"y":2,"w":44,"h":44},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":48,"h":48},
"sourceSize": {"w":48,"h":48}
},
"cbDown.png":
{
"frame": {"x":120,"y":455,"w":44,"h":44},
"frame": {"x":304,"y":335,"w":48,"h":48},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":2,"y":2,"w":44,"h":44},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":48,"h":48},
"sourceSize": {"w":48,"h":48}
},
"cbUnchecked.png":
{
"frame": {"x":75,"y":455,"w":44,"h":44},
"frame": {"x":255,"y":335,"w":48,"h":48},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":2,"y":2,"w":44,"h":44},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":48,"h":48},
"sourceSize": {"w":48,"h":48}
},
"emptyDown.png":
Expand Down Expand Up @@ -162,98 +162,98 @@
},
"marioPanel.png":
{
"frame": {"x":254,"y":1,"w":246,"h":246},
"frame": {"x":254,"y":1,"w":250,"h":250},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":2,"y":1,"w":246,"h":246},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":250,"h":250},
"sourceSize": {"w":250,"h":250}
},
"optionsDown.png":
{
"frame": {"x":37,"y":340,"w":128,"h":50},
"frame": {"x":37,"y":310,"w":128,"h":50},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":50},
"sourceSize": {"w":128,"h":50}
},
"optionsUp.png":
{
"frame": {"x":232,"y":284,"w":128,"h":50},
"frame": {"x":37,"y":259,"w":128,"h":50},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":128,"h":50},
"sourceSize": {"w":128,"h":50}
},
"playDown.png":
{
"frame": {"x":37,"y":294,"w":139,"h":45},
"frame": {"x":37,"y":213,"w":139,"h":45},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":139,"h":45},
"sourceSize": {"w":139,"h":45}
},
"playUp.png":
{
"frame": {"x":37,"y":248,"w":139,"h":45},
"frame": {"x":37,"y":167,"w":139,"h":45},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":139,"h":45},
"sourceSize": {"w":139,"h":45}
},
"progressBar.png":
{
"frame": {"x":232,"y":269,"w":190,"h":14},
"frame": {"x":242,"y":273,"w":190,"h":14},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":190,"h":14},
"sourceSize": {"w":190,"h":14}
},
"progressBarBorder.png":
{
"frame": {"x":232,"y":248,"w":200,"h":20},
"frame": {"x":242,"y":252,"w":200,"h":20},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":200,"h":20},
"sourceSize": {"w":200,"h":20}
},
"scoresDown.png":
{
"frame": {"x":224,"y":335,"w":125,"h":46},
"frame": {"x":381,"y":317,"w":125,"h":46},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":125,"h":46},
"sourceSize": {"w":125,"h":46}
},
"scoresUp.png":
{
"frame": {"x":361,"y":301,"w":125,"h":46},
"frame": {"x":255,"y":288,"w":125,"h":46},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":125,"h":46},
"sourceSize": {"w":125,"h":46}
},
"sliderKnob.png":
{
"frame": {"x":177,"y":189,"w":55,"h":55},
"frame": {"x":246,"y":449,"w":55,"h":55},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":55,"h":55},
"sourceSize": {"w":55,"h":55}
},
"vSlider.png":
{
"frame": {"x":1,"y":248,"w":35,"h":252},
"frame": {"x":1,"y":252,"w":35,"h":252},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":35,"h":252},
"sourceSize": {"w":35,"h":252}
},
"vSliderKnob.png":
{
"frame": {"x":82,"y":167,"w":53,"h":67},
"frame": {"x":37,"y":361,"w":55,"h":69},
"rotated": false,
"trimmed": true,
"spriteSourceSize": {"x":1,"y":1,"w":53,"h":67},
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":55,"h":69},
"sourceSize": {"w":55,"h":69}
},
"vertPanelBottom.png":
Expand All @@ -266,7 +266,7 @@
},
"vertPanelMiddle.png":
{
"frame": {"x":1,"y":501,"w":175,"h":5},
"frame": {"x":1,"y":505,"w":175,"h":5},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":175,"h":5},
Expand All @@ -287,6 +287,6 @@
"format": "RGBA8888",
"size": {"w":512,"h":512},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:9305829291cd21406f0df522013db26a$"
"smartupdate": "$TexturePacker:SmartUpdate:c6953e2503c4f5f54ded0a24c3cca24f$"
}
}
7 changes: 3 additions & 4 deletions Assets/DemoSceneScripts/ScrollableContainerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void Start()
var scrollable = new UIScrollableVerticalLayout( 10 );
scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
scrollable.position = new Vector3( 0, -50, 0 );
var width = UI.isHD ? 300 : 150;
var width = UI.scaleFactor * 150;
scrollable.setSize( width, Screen.height / 1.4f );

for( var i = 0; i < 20; i++ )
Expand Down Expand Up @@ -106,9 +106,8 @@ void Start()
scores.onTouchUpInside += ( sender ) =>
{
var target = scrollable.position;
var moveBy = _movedContainer ? -100 : 100;
if( !UI.isHD )
moveBy /= 2;
var moveBy = _movedContainer ? -50 : 50;
moveBy *= UI.scaleFactor;
target.x += moveBy * 2;
target.y += moveBy;
scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
Expand Down
12 changes: 7 additions & 5 deletions Assets/DemoSceneScripts/ScrollableHorizontalContainerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public class ScrollableHorizontalContainerManager : MonoBehaviour

void Start()
{
// add two scrollables: one with pageing enabled
// add two scrollables: one with paging enabled and one without
var scrollable = new UIScrollableHorizontalLayout( 10 );

// we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
scrollable.beginUpdates();

var height = UI.isHD ? 150 : 300;
var height = UI.scaleFactor * 50;
var width = Screen.width / 1.4f;
scrollable.setSize( width, height );
scrollable.position = new Vector3( ( Screen.width - width ) / 2, -Screen.height + height, 0 );
Expand Down Expand Up @@ -88,17 +88,18 @@ void Start()



// add another scrollable
// add another scrollable, this one with paging enabled
scrollable = new UIScrollableHorizontalLayout( 0 );

// we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
scrollable.beginUpdates();

var widthAndHeight = UI.isHD ? 500 : 250;
var widthAndHeight = UI.scaleFactor * 250f;
scrollable.setSize( widthAndHeight, widthAndHeight );
// paging will snap to the nearest page when scrolling
scrollable.pagingEnabled = true;

// paging will snap to the nearest page when scrolling
// center the scrollable horizontally
scrollable.position = new Vector3( ( Screen.width - widthAndHeight ) / 2, 0, 0 );

for( var i = 0; i < 5; i++ )
Expand All @@ -110,4 +111,5 @@ void Start()
scrollable.endUpdates();
scrollable.endUpdates(); // this is a bug. it shouldnt need to be called twice
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected virtual void layoutChildren()

// Set anchor offset
anchorInfo.OffsetX = ( _contentWidth + _scrollPosition ) * hdFactor;

// dont overwrite the sprites origin anchor!
anchorInfo.OriginUIxAnchor = item.anchorInfo.OriginUIxAnchor;
anchorInfo.OriginUIyAnchor = item.anchorInfo.OriginUIyAnchor;
Expand Down
Loading

0 comments on commit 60be20c

Please sign in to comment.