Tag Info

Hot answers tagged

13

You are looking for the wondrous atan2. // v1 moving object float boxX = this.mScene.getLastChild().getX(); float boxY = this.mScene.getLastChild().getY(); // v2 user touch float touchX = pSceneTouchEvent.getX(); float touchY = pSceneTouchEvent.getY(); double theta = 180.0 / Math.PI * Math.atan2(boxX - touchX, touchY - boxY); Normally it is used ...


13

Fundamentally, it looks like snow because the particles are round and they don't convey motion in any way. Rain drops are typically seen as elongated droplets, even to the point at which they are lines rather than particles. Think of a scene where you are looking out of a window at a rainstorm: you're not seeing individual drops suspended in the air, you're ...


12

The "ripple" effect you are showing is just a radial sinewave: sin(t), where t is the distance from some center. Image from here Doing this kind of deformation in a vertex or pixel shader is easy: just set up the center of the wave as a uniform variable waveCenter, then move every vertex in z (where z is the "up" direction) by MAGNITUDE*sin( FREQUENCY*t ...


8

What you want to do is something called LERP. Stands for Linear Interpolation, and you can do with the follow: If you know how many seconds have passed, and what is the total, you might do the follow: u = total / passedTime u is your "progress" variable, on a LERP. So, as your start value is 0 and the final value is 360, we do the following: current = ...


7

Move the camera (attached to your player). I would imagine that your world has multiple objects such as enemies. If you went with moving the world, you would have to loop through all these objects to update their positions every time the world moved. If you move the player, and attach the camera to the player then there is minimal resource usage. The game ...


7

When we rotate a object in 2d, each corner is a vector (x,y) away from the center. That vector has an angle. Get the offset of the selected corner from the center: cornerOffset.x = corner.x - center.x; cornerOffset.y = corner.y - center.y; To calculate this angle we do something like this in AS3 / Java angle = Math.Atan2(corner.y - center.y, ...


7

The mechanics for air hockey are not particularly deep, so it wouldn't take much to generate reasonable behavior. Think of the movement of the paddle as comprised of several different types of movement: Wander - to some extent people simply move the paddle around, both left and right and forward and back to keep the enemy guessing. Defend - blocking the ...


7

Color value basically consists of 4 single byte channel values, these 4 value represent R, G, B and transparency(A) of that color. An integer value is also a 4 byte value, so these two types are used interchangeably. Based on the name of the function you are using I'm guessing the R is packed as the byte with lowest value, and A is the highest value byte. so ...


6

USE GLES2 AndEngine is a little tricky to get configured properly the first time you try. I recommend installing the version stored at RealMayo's github, which is a stable version. That's a version of GLES2 and yes, it's definitely worthwhile to use GLES2 over GLES1. Many new features were added that make life easier, improve performance, and add great ...


5

Your question is a bit rough but if I'm following correctly, you want to make it so the background is stretched horizontally as it moves towards the bottom of the screen, giving it a somewhat isometric view and a more angled perspective. Just as a warning, I've no direct android development experience myself so this is going to be largely theoretical. ...


5

1) I think this is referenced here, and if not there's a decent community over there to ask. Even a bunch of tutorials/examples documented. 2) If I'm not mistaken I think you should always use transforms/forces to move anything associated with a body to correctly step with the Box2D physics...


5

Usual solution for concurrency problems is data isolation. Isolation means that every thread has its own data, and does not touch data of other threads. This way there are no problems with concurrency... but then we have problem of communication. How can these threads work together if they don't share any data? There are two approaches here. First one is ...


5

LoopEntityModifier is the way to go! Not sure, but it may end as something like this: LoopEntityModifier EntityModifier = new LoopEntityModifier( new RotationModifier(yourargs) );


5

I'm assuming you're talking about a joystick; one which, when active, always points toward your finger. It looks like your X and Y values are positions relative to one corner of the screen - so you're just measuring the angle from one corner of the screen to your finger. Of course it would never work! Well, unless your stick is on the corner of the screen. ...


5

To get the best result, you need to run the simulation like if you actually threw the projectile - just fast forward! And that is quite easy in any Box2D port. In AndEngine call method step(float timeStep, int velocityIterations, int positionIterations) from class com.badlogic.gdx.physics.box2d.World in a loop to run it as fast as you want. You can apply ...


5

In most update methods there is a delta, which provides the number of milliseconds (or some other measurement of time) since the last update was called. By calculating all of your movement calculations using both a delta and a movement speed, you get movement that is unaffected by a fluctuating frame rate. The following is code pulled from the movement ...


5

I'm not familiar with AndEngine, but the obvious general approach is to turn off collisions between the character and platforms whenever the character's vertical velocity is positive (i.e. the character is moving upwards). If your platforms (or character) have a non-negligible thickness, you may need to deal with the situation where the character partially ...


5

I believe what you're asking is how to get rid of letterboxing, like this: By default, AndEngine assumes you want some fixed aspect ratio. It then uses letterboxing to handle devices with different display aspect ratios then what you're providing. The advantage is you have certainty about your layout. There's more than one approach to get rid of ...


5

I add my code its for temporary code you can change this code set your life of player life = 10; final Sprite whiteSprite= new Sprite(0, 0, testRegion); scene.attachChild(whiteSprite); width = whiteSprite.getWidth(); scale = width/life; Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public ...


5

Yes, it is possible. AndEngine has a Level loader that can do exactly what you need. I recommend going through these tutorials. In the final tutorial, creating a whole game, one of the chapters talks about level creating and loading. Look for a class named SimpleLevelLoader.


4

Is it possible to use a separate thread for the game action? I'm wondering if the menu being activated is consuming the current thread (this is a guess based on my experience in programming applications in Java that use menus). I suspect that what's going on is that you have one main thread, and that by activating the menu your code is temporarily halted ...


4

Your problem is inherently serial -- you must complete an update of the simulation before you can render it. Offloading the simulation to a different thread simply means the main UI thread does nothing while the simulation thread ticks (which means it is blocked). The commonly held "best practice" for concurrency is not to put your rendering on one thread ...


4

Probably 99% of the computer programs written in history used just 1 thread and worked fine. I don't have any experience of the AndEngine but it's very rare to find systems that require threading, just several that could have benefited from it, given the right hardware. Traditionally, to do simulation and GUI/rendering in one thread, you simply do a bit of ...


4

Since the game state is going to be specific to your game, there isn't built in functionality for this in the engine. One solution would be to write the state information you want to keep to an XML file. Likely you'd want to load this saved state in your onStart() function. But really that's up to you and how you want your game to behave. There's a blog ...


4

While this isn't how, it should be noted that: (this will help with speed) You almost never see rain by itself, you only see it when it hits the ground or passes through a lit object (like a light post). The simplest way to mimic rain without drawing any rain particles is to add fog to the world and add raindrops to the world, with maybe a few rain streaks. ...


4

I suppose you could call it a collision, but it's more like an intersection. You can create a trigger zone that activates when the player enters it. A simple way of doing that would just create a list of these zones, then check to see if the player is inside them every frame or when the player moves. A zone is just two points, a min and a max. Then you can ...


4

additional condition to check visibility of sprite prevented second executions of die method physicsConnector = new PhysicsConnector(this,body,true,false) { @Override public void onUpdate(final float pSecondsElapsed) { super.onUpdate(pSecondsElapsed); if (!camera.isRectangularShapeVisible(_bullet) && _bullet.isVisible()) { ...


4

My second question is that my actual game scene uses bound camera and I perform scrolling on that camera but my other scene uses the normal camera. So in this situation what to do? how to use multiple camera for single engine? or how to reset available current camera? Our 3d game engine allows us to create as many render targets we wish. A render ...


4

It's not going to be easy. I don't know much about AndEngine, but I've developed some GLES 2 apps, and it is possible to run and test them inside an AVD (in the Android world, "Virtual Device", or AVD is the correct term, not "emulator"). Looking at the logcat, I can see that there is a first exception: 02-23 15:18:50.983: D/AndEngine(636): ...


4

Add this permission to your Manifest.xml file <uses-permission android:name="android.permission.VIBRATE" /> and when there is a collision or something like that (I assume that you're handle the collision detection with AndEngine) you can add this code : // this is how you get an instance of Vibrator from current Context Vibrator v = (Vibrator) ...



Only top voted, non community-wiki answers of a minimum length are eligible