Skip to content

Commit

Permalink
Remove codeblocks plugin (cocos2d#183)
Browse files Browse the repository at this point in the history
* removed codeblocks, fixed formatting, added GFM link

* removed codeblocks, fixed formatting issues

* fixed formatting

* removed codeblocks plugin

* updated to match deploy_cron.sh

* EN changes

* ZH changes
  • Loading branch information
slackmoehrle authored Nov 6, 2018
1 parent c524f1b commit 398fa76
Show file tree
Hide file tree
Showing 116 changed files with 779 additions and 711 deletions.
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
#Cocos Documentation User Manual
# Cocos Documentation User Manual

###Contributing to these docs
### Contributing to these docs
Contributions to the Cocos documentation are always welcome. To edit a document, please fork the Cocos [docs repository](https://github.com/cocos2d/cocos2d-x-docs).

Notes:
- Fork our [docs repo](https://github.com/cocos2d/cocos2d-x-docs)
- The __en/__ directory contains English contributions. The __zh/__ directory contains 中文 contributions.
- Code blocks must be wrapped in this special code to work correctly:
- C++ only code block:
```html
{% codetabs name="C++", type="cpp" -%}
auto mySprite = Sprite::create("mysprite.png", Rect(0,0,40,40));
{%- endcodetabs %}
- code blocks must be wrapped in a markdown codeblock. For Markdown help, please see [GitHub Flavored Markdown](https://github.github.com/gfm/)
- Changes must be tested using `gitbook build` and `gitbook serve`, and must be tested in multiple web browsers. For more information, see the [Requirements](#Requirements) section below.
- Submit completed changes via a *pull request* so they can be reviewed and merged.

###Requirements
### Requirements
This documentation site is powered by [GitBook](https://www.gitbook.com/). You need [Node.js](https://nodejs.org/en/) and npm to be able to build it.

To install gitbook:
Expand All @@ -29,7 +25,7 @@ To install gitbook plugins:
gitbook install
```

###Preview and Build
### Preview and Build
To preview the documentation site, run the following command in the cocos2d-x-docs directory:

```bash
Expand Down
3 changes: 1 addition & 2 deletions book.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"search-title",
"anchorjs",
"toggle-chapters",
"sharing",
"codetabs"
"sharing"
],
"styles": {
"website": "./styles/website.css"
Expand Down
149 changes: 115 additions & 34 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# This script builds: Cocos2d-x-docs, Cocos Creator Manual, Cocos Creator API-Ref.

# on production this script should be run as:
# (cd /data/home/docops/cocos2d-x-docs && exec /data/home/docops/cocos2d-x-docs/deploy_cron.sh)

echo "-----------------"
echo "Cocos2d-x-docs..."
echo "-----------------"
Expand All @@ -22,85 +25,163 @@ gitbook build

## copy some needed files
echo "Cocos2d-x-docs -- copying needed files..."
cp index.html.en _book/index.html
cp ../api-refs-static-pages.tar.gz _book/.
cp ../editors_and_tools.tar.gz _book/.
cp redirect.html.en _book/index.html
cp index.html.en ../documentation/index.html

## copy everything to deployment directory
cd _book/

echo "Cocos2d-x-docs -- extracting everything..."
tar xvf api-refs-static-pages.tar.gz
tar xvf editors_and_tools.tar.gz

echo "Cocos2d-x-docs -- removing unneeded files..."
rm -rf api-refs-static-pages.tar.gz
rm -rf editors_and_tools.tar.gz

cd ..
echo "Cocos2d-x-docs -- copy everything to deployment directory..."

mv _book/ cocos2d-x/

rsync --recursive cocos2d-x ../documentation

rm -rf cocos2d-x/

git stash

echo "-----------------------"
echo "Cocos Creator Manual..."
echo "-----------------------"
## pull latest from github
echo "Cocos Creator -- pulling latest from GitHub..."
echo "Cocos Creator -- building documentation..."
cd ../creator-docs
git pull origin master

## pulling legacy version
echo "Cocos Creator -- pulling v1.9..."
git checkout v1.9
git pull origin v1.9
cp -rf config/cocos2d-x.org/. ./

## make sure gitbook is up to date
echo "Cocos Creator -- building GitBook docs...."
echo "If this is your first time build this repo, please stop this process and run:"
echo "npm install gulp -g"
echo "npm install"
echo "DO NOT COMMIT: package-lock.json"
sudo npm install gulp -g
sudo npm install
echo "Cocos Creator -- ensuring GitBook is up to date..."
gitbook install
npm run build
echo "Cocos Creator -- copy everything to deployment directory..."
cp ../cocos2d-x-docs/redirect.html.en _book/index.html
mv _book/ manual/
rsync --recursive manual ../documentation/creator/1.9
rm -rf manual/
git stash

## build it, this repo uses npm to build
## pulling previous version
echo "Cocos Creator -- pulling v1.10..."
git checkout master
git pull origin master
cp -rf config/cocos2d-x.org/. ./
echo "Cocos Creator -- building GitBook docs...."
echo "If this is your first time build this repo, please stop this process and run:"
echo "npm install gulp -g"
echo "npm install"
echo "DO NOT COMMIT: package-lock.json"
npm install gulp -g
npm install
sudo npm install gulp -g
sudo npm install
echo "Cocos Creator -- ensuring GitBook is up to date..."
gitbook install
npm run build

## copy everything to deployment directory
echo "Cocos Creator -- copy everything to deployment directory..."
cp ../cocos2d-x-docs/redirect.html.en _book/index.html
mv _book/ manual/
rsync --recursive manual ../documentation/creator/1.10
rm -rf manual/
git stash

## pulling next version
echo "Cocos Creator -- pulling v2.x.."
git checkout next
git pull origin next
cp -rf config/cocos2d-x.org/. ./
echo "Cocos Creator -- building GitBook docs...."
echo "If this is your first time build this repo, please stop this process and run:"
echo "npm install gulp -g"
echo "npm install"
echo "DO NOT COMMIT: package-lock.json"
sudo npm install gulp -g
sudo npm install
echo "Cocos Creator -- ensuring GitBook is up to date..."
gitbook install
npm run build
echo "Cocos Creator -- copy everything to deployment directory..."
cp ../cocos2d-x-docs/redirect.html.en _book/index.html
mv _book/ manual/
rsync --recursive manual ../documentation/creator

rm -rf manual/
git stash

echo "------------------------"
echo "Cocos Creator API-Ref..."
echo "------------------------"
## pull latest from github
echo "Cocos Creator API -- pulling latest from GitHub..."
echo "Cocos Creator API -- building documentation..."
cd ../creator-api-docs
git pull origin master

echo "Cocos Creator API - pulling legacy version..."
git checkout v1.9
git pull origin v1.9
cp -rf config/cocos2d-x.org/. ./

## make sure gitbook is up to date
echo "Cocos Creator API -- ensuring GitBook is up to date..."
gitbook install
echo "Cocos Creator API -- building GitBook docs...."
gitbook build
echo "Cocos Creator API -- copy everything to deployment directory..."
cp ../cocos2d-x-docs/redirect.html.en _book/index.html
mv _book/ v1.9/
rsync --recursive v1.9 ../documentation/api-ref/creator
mv v1.9/ api/
rsync --recursive api ../documentation/creator/1.9

## build it

#rm -rf ../documentation/api-ref/creator/v1.9/
#mv ../documentation/api-ref/creator/api/ ../documentation/api-ref/creator/v1.9/

rm -rf api/
git stash

echo "Cocos Creator API - pulling previous version..."
git checkout master
git pull origin master
cp -rf config/cocos2d-x.org/. ./
echo "Cocos Creator API -- ensuring GitBook is up to date..."
gitbook install
echo "Cocos Creator API -- building GitBook docs...."
gitbook build
echo "Cocos Creator API -- copy everything to deployment directory..."
cp ../cocos2d-x-docs/redirect.html.en _book/index.html
mv _book/ v1.10/
rsync --recursive v1.10 ../documentation/api-ref/creator
mv v1.10/ api/
rsync --recursive api ../documentation/creator/1.10

## copy everything to deployment directory

#rm -rf ../documentation/api-ref/creator/v1.9/
#mv ../documentation/api-ref/creator/api/ ../documentation/api-ref/creator/v1.9/

rm -rf api/
git stash

echo "Cocos Creator API - pulling current version..."
git checkout v2.0
git pull origin v2.0
cp -rf config/cocos2d-x.org/. ./
echo "Cocos Creator API -- ensuring GitBook is up to date..."
gitbook install
echo "Cocos Creator API -- building GitBook docs...."
gitbook build
echo "Cocos Creator API -- copy everything to deployment directory..."
cp ../cocos2d-x-docs/index.html.en _book/index.html
mv _book/ creator-api/
cp ../cocos2d-x-docs/redirect.html.en _book/index.html
mv _book/ api/
rsync --recursive api ../documentation/creator/
mv api/ v2.0/
rsync --recursive v2.0 ../documentation/api-ref/creator

rsync --recursive creator-api ../documentation
#rm -rf ../documentation/api-ref/creator/v1.9/
#mv ../documentation/api-ref/creator/api/ ../documentation/api-ref/creator/v1.9/

rm -rf creator-api/
rm -rf v2.0/
git stash

cd ..
32 changes: 16 additions & 16 deletions en/3d/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ This is how `Camera` and `Billboard` objects relate to each other.
it supports most of the features as a `Sprite` object. We can create one using the
following create method:

{% codetabs name="C++", type="cpp" -%}
```cpp
auto billboard = BillBoard::create("Blue_Front1.png", BillBoard::Mode::VIEW_POINT_ORIENTED);
{%- endcodetabs %}
```

You can also create a `Billboard` object for the camera XOY plane (like the plane
of a floor) by changing the `BillBoard` objects mode:

{% codetabs name="C++", type="cpp" -%}
```cpp
auto billboard = BillBoard::create("Blue_Front1.png", BillBoard::Mode::VIEW_PLANE_ORIENTED);
{%- endcodetabs %}
```

These _create_ methods look a little different since an additional parameter of
__BillBoard::Mode__ is passed in. There are two __BillBoard::Mode__ types,
Expand All @@ -45,12 +45,12 @@ You can also set properties for a `BillBoard` just like with any other `Node`.
These include, but are not limited to: __scale__, __position__, __rotation__.
Examples:

{% codetabs name="C++", type="cpp" -%}
```cpp
billboard->setScale(0.5f);
billboard->setPosition3D(Vec3(0.0f, 0.0f, 0.0f));
billboard->setBlendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED);
addChild(billboard);
{%- endcodetabs %}
```
### ParticleSystem3D
In Chapter 7, you learned about 2D particles and how to use them. When you use 3D
Expand All @@ -73,23 +73,23 @@ The first way is to build a particle by passing in a __Particle Universe__ file
and its corresponding __material file__. Remember from Chapter 7 that a
__material file__ is what describes the particle. This is required. Example:
{% codetabs name="C++", type="cpp" -%}
```cpp
auto ps = PUParticleSystem3D::create("lineStreak.pu", "pu_mediapack_01.material");
ps->startParticleSystem();
this->addChild(ps);
{%- endcodetabs %}
```

The second way is to build the particle system only by passing a __particle universe__
file. When you create a particle this way, besides loading the particle, all
__material files__ in the same folder as the particle file will automatically be
loaded. Here is an example:

{% codetabs name="C++", type="cpp" -%}
```cpp
auto ps = PUParticleSystem3D::create("electricBeamSystem.pu");
ps->startParticleSystem();

this->addChild(ps);
{%- endcodetabs %}
```
__Note:__ using this method will result in an increase in loading times and
consumes more memory since everything will be loaded. If you know what __material__
Expand All @@ -105,18 +105,18 @@ Once you have your particle, you can interact with it it fairly obvious ways. Yo
can interact with with the __particle system__ as a whole, starting, stopping,
pausing, resuming and obtaining the total number of particles:
{% codetabs name="C++", type="cpp" -%}
```cpp
virtual void startParticleSystem() override;
virtual void stopParticleSystem() override;
virtual void pauseParticleSystem() override;
virtual void resumeParticleSystem() override;
virtual int getAliveParticleCount() const override;
{%- endcodetabs %}
```

As `PUParticleSystem3D` is derived from `Node` you can run `Action` and `Sequence`
objects on your particles! Example:

{% codetabs name="C++", type="cpp" -%}
```cpp
auto ps = PUParticleSystem3D::create("blackHole.pu", "pu_mediapack_01.material");
ps->setPosition(-25.0f, 0.0f);

Expand All @@ -125,7 +125,7 @@ auto moveby1 = MoveBy::create(2.0f, Vec2(-50.0f, 0.0f));

ps->runAction(RepeatForever::create(Sequence::create(moveby, moveby1, nullptr)));
ps->startParticleSystem();
{%- endcodetabs %}
```
Combining `Action` and `Sequence` objects could produce an interesting black hole
effect:
Expand All @@ -135,7 +135,7 @@ effect:
Just like with other 3D objects you can also combine 3D objects using `AttachNode`.
This allows for creating rich models. Example:
{% codetabs name="C++", type="cpp" -%}
```cpp
auto sprite3d = Sprite3D::create("orc.c3b");
sprite3d->setPosition3D(Vec3(0.0f, 0.0f, 0.0f));
sprite3d->setRotation3D(Vec3(0.0f, 180.0f, 0.0f));
Expand All @@ -152,6 +152,6 @@ handler->startParticleSystem();
sprite3d->getAttachNode("Bip001 L Hand")->addChild(handler);
this->addChild(sprite3d);
{%- endcodetabs %}
```

![](3d-img/particle4.png)
Loading

0 comments on commit 398fa76

Please sign in to comment.