@@ -2,8 +2,13 @@ import React, { Component, PropTypes } from 'react';
22import Gamepad from 'html5-gamepad' ;
33
44import Basics from './basics' ;
5+ import Loop from './loop' ;
6+ import Scaling from './scaling' ;
7+ import Sprites from './sprites' ;
8+ import TileMaps from './tilemaps' ;
9+ import Physics from './physics' ;
510
6- const slides = [ Basics ] ;
11+ const slides = [ Basics , Loop , Scaling , Sprites , TileMaps , Physics ] ;
712
813const gamepad = new Gamepad ( ) ;
914
@@ -28,12 +33,12 @@ export default class Slides extends Component {
2833 }
2934
3035 if ( gamepad . button ( 0 , 'button 14' ) ) {
31- this . handlePrev ( ) ;
36+ this . handlePrev ( true ) ;
3237 return ;
3338 }
3439
3540 if ( gamepad . button ( 0 , 'button 15' ) ) {
36- this . handleNext ( ) ;
41+ this . handleNext ( true ) ;
3742 return ;
3843 }
3944
@@ -54,7 +59,7 @@ export default class Slides extends Component {
5459 }
5560 }
5661
57- handleNext ( ) {
62+ handleNext ( restartLoop ) {
5863 const { currentSlide } = this . state ;
5964 const { index } = this . props ;
6065
@@ -64,20 +69,28 @@ export default class Slides extends Component {
6469 this . setState ( {
6570 currentSlide : currentSlide + 1 ,
6671 } , ( ) => {
67- this . restartLoop ( ) ;
72+ if ( restartLoop ) {
73+ this . restartLoop ( ) ;
74+ }
6875 } ) ;
6976 }
7077 }
7178
72- handlePrev ( ) {
79+ handlePrev ( restartLoop ) {
7380 const { currentSlide } = this . state ;
7481
7582 if ( currentSlide !== 0 ) {
7683 this . setState ( {
7784 currentSlide : currentSlide - 1 ,
7885 } , ( ) => {
79- this . restartLoop ( ) ;
86+ if ( restartLoop ) {
87+ this . restartLoop ( ) ;
88+ }
8089 } ) ;
90+ } else {
91+ if ( restartLoop ) {
92+ this . restartLoop ( ) ;
93+ }
8194 }
8295 }
8396
0 commit comments