diff --git a/src/App.css b/src/App.css
index 441dacf..eea9963 100644
--- a/src/App.css
+++ b/src/App.css
@@ -30,7 +30,7 @@ body {
margin: 5px;
cursor: pointer;
- animation-duration: 4s;
+ animation-duration: 4s; /* orig 4s */
animation-name: item-move;
animation-timing-function: linear;
diff --git a/src/App.js b/src/App.js
index 1ca7b71..a9e342b 100644
--- a/src/App.js
+++ b/src/App.js
@@ -25,32 +25,46 @@ class App extends Component {
super();
this.state = {
- items: [],
+ items: [], /* item array keeps track of items and if they've been spotted */
points: 0,
};
// Uncomment this to spawn a single test item
- //const testItem = this.spawnItem(Date.now());
- //this.state.items.push(testItem);
+ // const testItem = this.spawnItem(Date.now());
+ // this.state.items.push(testItem);
// Uncomment this to automatically spawn new items
this.enableSpawner();
- console.log(this.state);
+ // console.log(this.state);
}
- onItemClicked = () => {
+ onItemClicked = (index) => {
// Fill this in!
+ // This click handler is passed via props to GameItem
+ console.log("Item was clicked");
+ // identify item clicked on
+ console.log(index);
+ // change it's state to spotted
+ let updatedItemData = this.state.items;
+ updatedItemData[index].wasSpotted = true;
+ this.setState({items: updatedItemData});
+ console.log(this.state.items[index]);
}
render() {
+ // mapping over item array from state to create array of GameItems
+ // array of GameItems to be returned in return statement
const items = this.state.items.map((item, i) => {
return