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
430c08f3
Commit
430c08f3
authored
Jul 29, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds display of last score to demo game
parent
f99fd192
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
16 deletions
+32
-16
game_demo.dart
packages/flutter/example/game/lib/game_demo.dart
+2
-0
game_demo_world.dart
packages/flutter/example/game/lib/game_demo_world.dart
+1
-0
main.dart
packages/flutter/example/game/main.dart
+29
-16
No files found.
packages/flutter/example/game/lib/game_demo.dart
View file @
430c08f3
...
@@ -9,4 +9,6 @@ import 'package:sky/widgets/widget.dart';
...
@@ -9,4 +9,6 @@ import 'package:sky/widgets/widget.dart';
import
'package:sky/widgets/navigator.dart'
;
import
'package:sky/widgets/navigator.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'../main.dart'
;
part
'game_demo_world.dart'
;
part
'game_demo_world.dart'
;
packages/flutter/example/game/lib/game_demo_world.dart
View file @
430c08f3
...
@@ -348,6 +348,7 @@ class GameDemoWorld extends NodeWithSize {
...
@@ -348,6 +348,7 @@ class GameDemoWorld extends NodeWithSize {
// Set game over
// Set game over
_isGameOver
=
true
;
_isGameOver
=
true
;
lastScore
=
_hud
.
score
;
// Remove the ship
// Remove the ship
_ship
.
visible
=
false
;
_ship
.
visible
=
false
;
...
...
packages/flutter/example/game/main.dart
View file @
430c08f3
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'package:sky/mojo/asset_bundle.dart'
;
import
'package:sky/mojo/asset_bundle.dart'
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/theme/colors.dart'
as
colors
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/painting/text_style.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/basic.dart'
;
import
'package:sky/widgets/button_base.dart'
;
import
'package:sky/widgets/button_base.dart'
;
import
'package:sky/widgets/navigator.dart'
;
import
'package:sky/widgets/navigator.dart'
;
...
@@ -93,27 +94,37 @@ class GameDemoApp extends App {
...
@@ -93,27 +94,37 @@ class GameDemoApp extends App {
return
new
Stack
([
return
new
Stack
([
new
SpriteWidget
(
new
MainScreenBackground
()),
new
SpriteWidget
(
new
MainScreenBackground
()),
new
Center
(
new
Center
(
child:
new
TextureButton
(
child:
new
Flex
([
onPressed:
()
{
new
TextureButton
(
_game
=
new
GameDemoWorld
(
onPressed:
()
{
_app
,
_game
=
new
GameDemoWorld
(
navigator
,
_app
,
_loader
,
navigator
,
_spriteSheet
,
_loader
,
_spriteSheetUI
_spriteSheet
,
);
_spriteSheetUI
navigator
.
pushNamed
(
'/game'
);
);
},
navigator
.
pushNamed
(
'/game'
);
texture:
_spriteSheetUI
[
"btn_play_up.png"
],
},
textureDown:
_spriteSheetUI
[
"btn_play_down.png"
],
texture:
_spriteSheetUI
[
"btn_play_up.png"
],
width:
128.0
,
textureDown:
_spriteSheetUI
[
"btn_play_down.png"
],
height:
128.0
width:
128.0
,
)
height:
128.0
),
new
Text
(
"Last Score:
$lastScore
"
,
style:
new
TextStyle
(
fontSize:
20.0
)
)
],
direction:
FlexDirection
.
vertical
,
justifyContent:
FlexJustifyContent
.
center
)
)
)
]);
]);
}
}
}
}
int
lastScore
=
0
;
class
TextureButton
extends
ButtonBase
{
class
TextureButton
extends
ButtonBase
{
TextureButton
({
TextureButton
({
Key
key
,
Key
key
,
...
@@ -156,6 +167,7 @@ class TextureButton extends ButtonBase {
...
@@ -156,6 +167,7 @@ class TextureButton extends ButtonBase {
if
(
texture
==
null
)
if
(
texture
==
null
)
return
;
return
;
canvas
.
save
();
if
(
highlight
&&
textureDown
!=
null
)
{
if
(
highlight
&&
textureDown
!=
null
)
{
// Draw down state
// Draw down state
canvas
.
scale
(
size
.
width
/
textureDown
.
size
.
width
,
size
.
height
/
textureDown
.
size
.
height
);
canvas
.
scale
(
size
.
width
/
textureDown
.
size
.
width
,
size
.
height
/
textureDown
.
size
.
height
);
...
@@ -165,6 +177,7 @@ class TextureButton extends ButtonBase {
...
@@ -165,6 +177,7 @@ class TextureButton extends ButtonBase {
canvas
.
scale
(
size
.
width
/
texture
.
size
.
width
,
size
.
height
/
texture
.
size
.
height
);
canvas
.
scale
(
size
.
width
/
texture
.
size
.
width
,
size
.
height
/
texture
.
size
.
height
);
texture
.
drawTexture
(
canvas
,
Point
.
origin
,
new
Paint
());
texture
.
drawTexture
(
canvas
,
Point
.
origin
,
new
Paint
());
}
}
canvas
.
restore
();
}
}
}
}
...
...
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