Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/characters/ninja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ui';

import 'package:box2d_flame/box2d.dart';
import 'package:flame/box2d/box2d_component.dart';
import 'package:flame/flame.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/painting.dart';

Expand Down Expand Up @@ -45,11 +46,14 @@ class NinjaComponent extends BodyComponent {
return;
}

var timer = new DateTime.now();
var index = (timer.millisecond / 60 % 9).round();

paintImage(
canvas: canvas,
image: this.jumping
? images.get("glide-0")
: this.idle ? images.get("idle-0") : images.get("run-0"),
? images.get("glide-$index")
: this.idle ? images.get("idle-$index") : images.get("run-$index"),
rect: new Rect.fromCircle(center: center, radius: radius),
flipHorizontally: !this.forward,
fit: BoxFit.contain);
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ main() {
Flame.util.fullScreen();

SystemChrome
.setPreferredOrientations([DeviceOrientation.landscapeRight]).then((_) {
.setPreferredOrientations([DeviceOrientation.portraitUp]).then((_) {
runApp(new HauntGame().widget);
});
}
4 changes: 2 additions & 2 deletions lib/ninja_world.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'levels/demo.dart';
class NinjaWorld extends Box2DComponent {
NinjaComponent ninja;

NinjaWorld() : super(scale: 4.0);
NinjaWorld() : super(scale: 4.0, gravity: -10.0);

void initializeWorld() {
// add(new GroundComponent(this));
Expand All @@ -21,7 +21,7 @@ class NinjaWorld extends Box2DComponent {
@override
void update(t) {
super.update(t);
cameraFollow(ninja, horizontal: 0.4, vertical: 0.4);
cameraFollow(ninja, horizontal: 0.2, vertical: 1.0);
}

void handleTap(Offset position) {
Expand Down
8 changes: 6 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
name: haunt
description: Haunt Flame Game

version: 1.0.0+1

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
screen:
flutter:
sdk: flutter

flame:
path: ../flame
flame: 0.9.4

dev_dependencies:
flutter_test:
Expand Down