I'm currently building a platformer in cocos2d-x and therefore i'm using a tmxtiledmap and chipmunk physics. My problem is that in the moment EACH tile of the map gets its own physics body which obviously isnt really memory saving:D
Is there any method to "recognize" that multiple tiles are next to each other and therefore only need one physics body?
Greets FreezZl
How are you creating the physics bodies?I dont use chipmunk, but had used box2d with Tiled and created a single Physics body for each platform by assigning an object to the whole platform in tiled and using that to create the physics body.
Related
Hello I have two smaller questions:
Is it possible to map the Shape of the Body 1:1 to the texture so I have a perfect collision detection ? Because right now I only know of two ways to do it: Create the Shape before and load it up with a texture or load the texture first and then set the shape as a box ... But that is too simple I think.
Also does anyone know how I can turn off the physics of the world ? When Body A hits Body B I want the Body to do a certain animation and fall to the ground with some sound effects, but when the two objects collide they bounce off each other in different directions etc. When two objects collide I want it to be "Game over" basically and stop calculating momentum etc.
I dont care about the solution itself, just telling me if its possible at all for both questions would be enough.
I guess you are using Box2d
Is it possible to map the Shape of the Body 1:1 to the texture so I
have a perfect collision detection ?
It possible, you can use PolygonShape in Box2D, but it has to be a convex polygon. Furthermore it slower then predefined shapes.
Also does anyone know how I can turn off the physics of the world ?
With box2d Physics you can simply stop the simulation on your own by not executing the world.step() command
In my game I have some gold that the player can collect. My problem is I want to individually refernce textures of gold so i can take that particular instance of gold off the screen (player picked it up). How would I go about doing this as i am pretty sure you cannot do this with regular textures. Would i have to create a shape and fill it with the gold texture so I can delete that particualr gold piece? Thanks
I think you confuse Texture (which is basically a loaded image that you can draw) with game entities. Depending on how you implement your game, you can spawn multiple bodies (Box2D), actors (Scene2D) or your simple data containers (width, height, x, y) representing each coin and draw each one on the screen using the same texture. Actually, that's the preferred way to handle assets: you load images once and then simply reuse them for each sprite.
I suggest looking into the following classes:
Sprite (makes it easier to draw textures).
Image (allows to display simple images on Scene2D stage).
Box2DSprite (third party utility class that makes it easier to draw Box2D worlds).
My iOS game contains many tiles, and each of the tiles are animated. I have about 30 animated tiles. Now my question is: can i create dragon bones for each animation and store them in a starling sprite sheet?
Yes you can, I haven't done it but from what I understand (from this conversation)[http://forum.starling-framework.org/topic/getting-all-assets-together-in-one-atlas#post-19274], one can edit a DragonBones atlas and add his own assets as well. Then use it as he would normally use his own Atlas.
I'm a beginner to AS3 and programming in general, but have learned enough that I want to now start learning how to render animations on the screen. These are the methods that I know of from two days of "researching" on google.
I'm not in a situation where I could afford to take courses from an educational institution, so my only means of learning are through online sources.
Update an objects x or y positions in a loop on every frame. Very basic. Of course any kind of advanced animation (say, showing a character running) is not possible with this method alone.
Using Flash and creating animation on a movie clip's timeline and, combined with moving the position of the object we can achieve some proper animation this way. However I cannot afford Flash, so this is not an option available to me. It also doesn't seem to be a popular option among more experienced programmers either (I think, due to having poor performance when lots of objects animating on the screen?)
Using a sprite sheet and then blitting the relevant image from the sprite sheet onto the screen.
Is there any other way to put an image from a sprite sheet onto the screen other than blitting?
And what other methods of rendering animation are available?
Some online websites claim that blitting is all I'll ever need, but I want to know all the options available so I could choose the most appropriate one for any given situation.
Any help would be appreciated :)
Another option for blitting is Stage3D. Take a look at Starling for 2D animations.
Blitting would be my best opinion. The only other thing I can think of is manually taking the images from the sprite sheet and putting it into each frame of an animation.
To render animation, you can create a frame in a MovieClip and convert it into a MovieClip and name the frame 'running'. Then you need to create an Enter Frame event where the MovieClip's instance name is 'Guy' and in the code on the function write 'Guy.x += 5;' to make your MovieClip go 5 pixels to the right every frame and also in the function write "Guy.gotoAndStop('running');"
Use TweenMax engine for better animation purposes. Easy coding, more Animation!!
i tried the hello example on the adobe site.
http://www.adobe.com/devnet/flashplayer/articles/hello-triangle.html
it works, but the context3D seems work on the stage's background in the lowest level. if i draw anything it will cover the 3d context.
i want to bring it to front or set it to a certain level. how can i do that?
also i was told if use 2d api and 3d api together , it will lower the performance of 3d,is it truth?In my works ,i still need 2d api ,for example, drawing the textfield .
Everything goes like this (from bottom to top):
StageVideo (1 or more instances) > Stage3D (1 or more instances) > Your regular display list.
And yes, regular display objects may degrade performance of Stage3D, therefore it may be better to use Stage3D alternatives of those. Some Stage3D accelerated frameworks already has some of those built in (like TextField in Starling).
No, you can't bring it to front.
2d and 3d not relates to each other. But of course, if you write 2d stuff that eat 100% of cpu, you'll get overal slow performance.
the only way is to get from the bottom layer of stage3D instance the rendered bitmap and display it on top of you displayList.. but it should work on each frame, thing that will affect the performance a lot and of course no mouse interaction... this solution will work only to display rendered scene on top of stage3D.. just a simulation