I am currently to development a game which is also can be seen on the tutorial on this link http://www.raywenderlich.com/33752/cocos2d-x-tutorial-for-ios-and-android-space-game
As I follow this tutorial, I encountered a problem on implementing the codes for adding child nodes on my ParallaxNode. My problem is... In the given tutorial, he used the statement: _backgroundNode->addChild(_spacedust1, 0, dustSpeed, ccp(winSize.height/2)); to add child on his parralaxnode. what I want to know is the equivalent ccp() function on cocos2dx version 3.2. because when I am trying to compile the game application, there are errors that are showing up.
CCPointMake or ccp is deprecated now and instead use Vec2 like:
Vec2(x, y) is equivalent of ccp(x, y)
Anyway if you use _backgroundNode->addChild(_spacedust1, 0, dustSpeed, ccp(winSize.height/2)); then this can't compile due incorrect syntax.
You have only one input in your code ccp(winSize.height/2) ccp, Point, Vec2 need two inputs x and y. Use Vec2(x,y) and will compile.
Related
Lately I realized that Chipmunk (am I right?) was integrated with >= Cocos2d-x 3.0. Now I am trying make use of it (I am using cocos2d-x 3.2).
So can you tell if it's possible to connect the bodies (PhysicsBody) with PhysicsJoint (eg. PhysicsJointSpring), but with connection points being placed for example on the edge of the body?
I saw the "Joints tests" from the package with library, but it looks like all of them (joints) are placed in the midlle of the body - you could say that anchor point is placed at Vec2(0.5f, 0.5f).
Test are here (PhysicsDemoJoints class):
https://github.com/cocos2d/cocos2d-x/blob/v3/tests/cpp-tests/Classes/PhysicsTest/PhysicsTest.cpp
Here is an example what I am talking about (two balls, left bottom corner):
https://www.youtube.com/watch?v=ZgJJZTS0aMM
I would appreciate any help! And give you an internet hight five as a gift!
In such cases take a look at the class reference.
You'll find that joints can be created with constructors similar to this one:
static PhysicsJointDistance * construct (PhysicsBody *a, PhysicsBody *b, const Vec2 &anchr1, const Vec2 &anchr2)
The two vectors are the joint anchor points. Unfortunately it's not documented what they are, but typically they'll be in world (scene) coordinates.
I am trying to use gestouch library in my project and i can't seem to get it to work properly.
This is how i am mapping it:
var tapGesture:TapGesture = new TapGesture(stage);
tapGesture.addEventListener(GestureEvent.GESTURE_RECOGNIZED, onTap);
As you can see it is mapped to the stage and this way it works...
The class where i am using it extends a flash Sprite, and i would like to map the gesture to
this, but when i do, gestouch doesn't seem to work...
I even tried putting a sprite with stage width and height on top of my view and still doesn't work...
Anyone knows what could be the problem?
Also, maybe it is important to note, i am using a ASC2.0, so i had to remove the mario mushroom operator from this part : Gestouch.inputAdapter ||= new NativeInputAdapter(stage);
I (am the author of Gestouch) haven't tested it with ASC 2.0 because it's still in development, but yea, at least it's known that there issues with "mushroom operator" and -inline compiler argument.
So the answer: stick to MXMLC or use sources and find out why it doesn't work.
Also it is better to ask questions on Github. I found this almost by accident — Google reports me of Gestouch mentions =)
I'm looking for a list of flash.include.whatever.whatever for as3.
If no one knows a list then can someone tell me the flash.include to use for drawing rectangle with the startFill and endFill things? Thanks for any help.
I didn't find anything on either of these googling, and the place I got the code for drawing a rectangle of course didn't have the flash.includes included in the example code... is their a reason so many people do that? Any way I can get around it?
Do you mean you want a list of the packages and classes that come with AS3? That is typically called the documentation and can be found here:
Adobe ActionScript® 3 API Reference
For drawing a Rectangle, you can start at flash.display.Shape. It has a graphics object with the methods .beginFill() and .endFill().
you can using a Graphics.
The Graphics class contains a set of methods that you can use to
create a vector shape. Display objects that support drawing include
Sprite and Shape objects. Each of these classes includes a graphics
property that is a Graphics object. The following are among those
helper functions provided for ease of use: drawRect(),
drawRoundRect(), drawCircle(), and drawEllipse(). You cannot create a
Graphics object directly from ActionScript code. If you call new
Graphics(), an exception is thrown.
The Graphics class is final; it cannot be subclassed.
here is a sample
import flash.display.*;
this.graphics.beginFill(0xff0000);
this.graphics.drawRect(0,0,100,100);
here is a Adobe Tutorial
AS3 all display class list here
You do not necessarily need to default AS3 include. fine compile. But include only the code you can see the hint. perhaps, CS4 after that if you use a specific class will automatically include. or ctrl+space is autocompletion.
As follows by default when you install the flash is because of the SWC path.
As per I know, there is not such a thing like Flash.include. May be you're trying to ask something else or may be i am still unknown about this feature.
If you found any positive thing about this, please let me know, i want to know that new thing.
I need to render some points with specified size using ShapeRenderer.
When using GL20, Gdx.gl and Gdx.gl20 will be initialized, while Gdx.gl10 and Gdx.gl11 will be null.
I can set line width and render using code such as this:
Gdx.gl.glLineWidth(5);
mShapeRenderer.begin(ShapeType.Rectangle);
mShapeRenderer.rect(0.0f, 0.0f, 50.0f, 50.0f);
mShapeRenderer.end();
But, from what I figured out, I can only set point size using Gdx.gl10.glPointSize(5) or Gdx.gl11.glPointSize(5) - which won't work in my case since both gl10 and gl11 are null.
Are there any simple solutions to this problem?
OpenGL ES dropped support for glPointSize (among other things) in 2.0, that's why you can't find it in Gdx.gl20, or in Gdx.gl.
Instead of setting a point size, just use ShapeRenderer's filledCircle to render the "large" points. (I would point to the API documentation, but they just changed the API last week and I'm not sure which version you are using.)
Are there any good open source SceneJS examples that can graph functions similar to those demonstrated in http://www.graphycalc.com/?
I haven't seen any but it should be relatively easy to simply use a custom vertex shader that transforms the vertices of a grid into your desired function: https://github.com/xeolabs/scenejs/wiki/shader
You can also use a data source plugin with a geometry node, to continually update it's mesh:
http://scenejs.org/examples.html?page=geometryPluginPullStream
http://scenejs.org/examples.html?page=geometryPluginPushStream
And here's the available vertex deformation examples (selected by tag, see left column, click one to load it):
http://scenejs.org/examples.html?tags=vertexDisplacement