mightycryptowall / cocos_planted_tree Goto Github PK
View Code? Open in Web Editor NEWPlanted Tree Tutorial in Cocos
Planted Tree Tutorial in Cocos
************ 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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.