Git Product home page Git Product logo

cocos_planted_tree's Introduction

************ Cocos Planted Tree ************

Technology Used
-> Cocos Creator Version 2.4.3
-> Google's Cloud Firestore
-> Typescript ( but mostly written in Javascript)


Scripts
-> GLOBALS.js
-> Prefabs_Collection.ts
-> FirebaseConnection.ts
-> GameManager.ts
-> Tree.ts

GLOBALS.js
-> Declare the path for the components.

Prefabs_Collection.ts 
-> This Scripts load the prefab (tree, apple_tree, orange_tree) from resource folder & store those in an trees array.
-> Consist of two accessor function getTrees & getTreeById.

FirebaseConnection.ts
-> This Script handle and insert data to/from the Firestore.
-> FirebaseConnection is initialized in onLoad function of this script.
-> Consist of two custom function loadTrees & saveTress.
-> loadTrees returns retrieve promise (for trees document) from the Firestore.
-> saveTrees take node array as an paramenter, covert those into object, batch those object firestore set function & commit to firestore.

GameManager.ts
-> This Script handle most of the function of this game.
-> Most of the component are initialized in onLoad function this script.
-> Have mouse click & mouse drag event listener in onLoad function.
-> Mouse click function call placeTree function.
-> placeTree function plant, move or delete tree base on the value in state variable.
-> Drag event listener call dragTree function.
-> dragTree function assign the mouse position value to the tree node position.
-> onLoad function also have click listener for btnPlant, btnMove, btnDelete, btnChange, btnSave, btnLoad.
-> btnPlant assign create value to the state variable.
-> btnMove assign move value to the state variable.
-> btnDelete assign delete value to the delete variable.
-> btnChange call the changeTree function.
-> btnSave call the save function.
-> btnLoad call the load function.

Tree.ts
Has listener for tree collision (onCollisionEnter, onCollisionStay,onCollisionExit).
These function toggle isPlaceable in GameManager.ts using setPlaceable function from the GameManager.ts.



cocos_planted_tree's People

Contributors

devyethiha avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.