Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
2bccb189
Commit
2bccb189
authored
Jul 23, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #249 from vlidholt/master
Adds test case for drawAtlas in games
parents
9ac68307
f3e51d9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
0 deletions
+84
-0
test_drawatlas.dart
packages/flutter/example/game/test_drawatlas.dart
+84
-0
No files found.
packages/flutter/example/game/test_drawatlas.dart
0 → 100644
View file @
2bccb189
import
'lib/sprites.dart'
;
import
'dart:sky'
;
import
'package:sky/mojo/asset_bundle.dart'
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/task_description.dart'
;
import
'package:sky/widgets/theme.dart'
;
AssetBundle
_initBundle
(
)
{
if
(
rootBundle
!=
null
)
return
rootBundle
;
return
new
NetworkAssetBundle
(
Uri
.
base
);
}
final
AssetBundle
_bundle
=
_initBundle
();
ImageMap
_images
;
SpriteSheet
_spriteSheet
;
TestDrawAtlasApp
_app
;
main
()
async
{
_images
=
new
ImageMap
(
_bundle
);
await
_images
.
load
([
'assets/sprites.png'
]);
String
json
=
await
_bundle
.
loadString
(
'assets/sprites.json'
);
_spriteSheet
=
new
SpriteSheet
(
_images
[
'assets/sprites.png'
],
json
);
_app
=
new
TestDrawAtlasApp
();
runApp
(
_app
);
}
class
TestDrawAtlasApp
extends
App
{
Widget
build
()
{
ThemeData
theme
=
new
ThemeData
(
brightness:
ThemeBrightness
.
light
,
primarySwatch:
colors
.
Purple
);
return
new
Theme
(
data:
theme
,
child:
new
TaskDescription
(
label:
'Test drawAtlas'
,
child:
new
SpriteWidget
(
new
TestDrawAtlas
(),
SpriteBoxTransformMode
.
fixedWidth
)
)
);
}
}
class
TestDrawAtlas
extends
NodeWithSize
{
TestDrawAtlas
()
:
super
(
new
Size
(
1024.0
,
1024.0
))
{
}
void
paint
(
PaintingCanvas
canvas
)
{
List
<
RSTransform
>
transforms
=
[
new
RSTransform
(
1.0
,
0.0
,
100.0
,
100.0
)
];
List
<
Rect
>
rects
=
[
_spriteSheet
[
"ship.png"
].
frame
];
List
<
Color
>
colors
=
[
new
Color
(
0xffffffff
)
];
canvas
.
drawAtlas
(
_spriteSheet
.
image
,
transforms
,
rects
,
colors
,
TransferMode
.
src
,
null
,
new
Paint
()..
setFilterQuality
(
FilterQuality
.
low
)..
isAntiAlias
=
false
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment