lbgdx - Particle Effect is not rendering - android

I have a problem attaching a Particle Effect, made by the particle editor, in my android code. It is just not rendered in runtime, even if the duration of the effect should be around 3 sec and it is positioned on the center of the screen.
As I can see some few other users faced with this kind of problem before but every answer they got didn't help me.
Here is my code:
// in creating
effect = new ParticleEffect();
effect.load(Gdx.files.internal("effects/prova2.p"), Gdx.files.internal("effects"));
effect.setPosition(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
effect.start();
//in rendering
effect.draw(game.batch, delta);
Also I tried to change "delta" with my world step value (1/40f) or calling Gdx.graphics.getDelta() but that doesn't seem to be the problem.

It seems like you're not updating the particle effect.
Try including:
effect.update(delta);
effect.draw(game.batch);

Related

Android Custom View Flickering

I've been trying to solve my problem for a long time now. However, I'm at a loss. The problem is this:
I have a Custom Android View that I render 10 rectangles on(kind of
like a bar chart all the same length, different color)
When updating one of the rectangles with different opacity, it
doesn't change. So I clear the Canvas. But this causes a flicker,
not all the time, but sometimes
What I've tried doing:
Render everything to an offscreen bitmap, then blting it, this still
doesn't solve my issue
Use a SurfaceView and render in another thread
A combination of 1 and 2
In the end, I think the problem is that the background gets erased, but I don't want it to erase. However, I can never get the new "pixels" to show up. I also tried experimenting with different transfer modes like SRC, SRC_ATOP, when I tried number 1, it helps, but does not get rid of the problem.
Does anyone have any guidance on what could be going wrong? Or any other possible solutions?
I have finally figured it out. I don't have to clear the back ground, just temporarily change the paint mode to SRC.
context.paint.setStyle(Paint.Style.FILL);
context.paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
context.canvas.drawPath(context.path, context.paint);
context.paint.setXfermode(null);

RenderScript "slow" blur

I've been fiddling around with RenderBlur on an image for my login screen, i've gotten everything to work with a runnable() and a delay to blur the image immediately, however i'm trying to make it a slow blur while the username and password fields come into view.
I've had a bit of a look around (could be looking in the wrong places) but I haven't found anything related to what i'm after. I've attempted to use a while loop and have a blurradius value increment with a delay afterwards and send to the blurBitmap class method, but it either still blurs it immediately (meaning I probably messed something up somewhere and will most likely keep trying with this method until a better solution is found).. or it crashes.
Does anyone know if, in the first place this is possible with RenderScript? And if so, what should I be searching for.
Thanks for any help you can provide.
Resources: https://futurestud.io/blog/how-to-use-the-renderscript-support-library-with-gradle-based-android-projects
You can do this with RenderScript, though how you are doing it now doesn't sound like a good idea. Look into using a custom Animator which you can then run a RS blur against the image. Using Animator will be more flexible in the long run and automatically ties in with the view system rather than requiring you to handle View or Activity state explicitly.
The approach #JasonWihardja outlined will also work, but again I would suggest doing this in an Animator or similar mechanism.
Blurring an image repeatedly might cause some performance issues with your app.
Here's what you could do:
Arrange 2 images (1 for the clear image and the other for the
maximum blur version) so that the blur image is placed exactly on
top of the clear image. The easiest way would be placing 2 ImageViews in a FrameLayout
To achieve the "slow" blur effect, initially set the blur image's alpha to 0.
Then, using one of the view, issue a postDelayed event to slowly increase the blur image's alpha to 255.

Android CircularFloatingActionMenu SlideDown

I am using this: CircularFloatingActionMenu
I have been able to use it so far pretty well. I am able to move it to desired positions as described in the ReadMe and even set rotation, theme coloring etc. My problem is I am trying to create a custom animation so that when placed in the upper right the icons shoot downwards. I kind of cheated and got it to appear to work by setting the start/end angle at 89 and 90 degrees so instead of being in a line they are just slightly off, but my problem is that when the animation finishes the final position ends up stacking all the icons on top of one another. I have attached screenshot demonstrating this.
Ive called my SlideDownAnimationHandler.java class as such:
FloatingActionMenu actionMenuTopRight = new FloatingActionMenu.Builder(this)
.setStartAngle(89)
.setEndAngle(90)
.setAnimationHandler(new SlideDownAnimationHandler())
.addSubActionView(rLSubBuilder.setContentView(rlIcon1).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon2).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon3).build())
//.addSubActionView(rLSubBuilder.setContentView(rlIcon4).build())
//.addSubActionView(rLSubBuilder.setContentView(rlIcon5).build())
.attachTo(darkButton)
.build();
I don't really want to post the SlideDownAnimationHandler.java classify as it is quite large (~100 lines of code). I'm wondering if theres a better way to properly animate the slide down effect, and also how to set their final position in a similar fashion to how i set the y translation in the animation itself.

Animated reveal for 14+ Android

I'm tackling the task of an overlaying drawable over a view that animates the drawing of a checkmark as in the following video https://vid.me/MsQj
I don't have a preferred method for doing this but it's just not coming out the way I wanted it to, I tried:
Two views, each with on side of the checkmark to be revealed with an animation, however I'm stuck at the "revealed with an animation" since I can't use the circular reveal on -21
Frame by frame animation, this is the easiest but I'd hate to have 60 images for this stupid animation if it can be done programmatically
Drawing on a custom view canvas
My question would be, is there anything that can make this easier on me, or do I have to tackle it head first and just get on with it
You could create a custom View class which contains two lines defined by ShapeDrawables, one for each leg of the tick. Expose the lengths of these two lines as properties of the class, and then use Property Animation to animate the lengths of the lines.
Property Animation is flexible enough to handle pretty complex timing and sequencing of various properties. In this particular case you would probably want to use an AnimatorSet to sequence the two line animations so the second starts once the first has finished.
I ended up developing a custom View thanks to #SoundConception suggestion and finding out about ObjectAnimator which are very powerful in Android. In essence what goes on is we set a width for the first and second line that make the checkmark and using the animator change the value of those properties from 0 to the desired one.
On the setter for the property, we invalidate the View to redraw it with the new value and with a little tweaking I made a nice View that while its currently only working for my specific layout (ie it needs some more work on the offset calculation) it's able to draw an animated checkmark with some stuff that is customizable.
Precisely, you can set the line width, the color, the length and the animation time. And touching the java file, you can change the interpolator and all the rest of the stuff.
Hopefully the code, while not really commented serves as a basis for someone trying something similar.
For example the following code would generate something like this video, although not really because I was testing opacity and thinner lines, but you get my drift.
<coop.devtopia.CheckmarkView
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_centerInParent="true"
android:id="#+id/view"
app:first_leg_length="50"
app:second_leg_length="100"
app:total_duration="1500"
app:stroke_width="20"
app:stroke_color="#22000000"/>
Repository
Update 4/2/15
I've played with this a little further and added dynamic offset calculation (fancy way of saying centering) to the tick, meaning we can generate big checkmarks, small checkmarks, skinny or thick, reversed or straight and they will be centered in the view. Can't guarantee the same for checkmarks bigger than the container, they will likely be cropped.
Here are a few of the checkmarks generated for this demonstration, of course the animate as if drawn and the effect can be very pleasing and resource friendly. This turn out to be a pretty interesting subject after all.

Libgdx animation , animates only on Animation.LOOP_RANDOM mode

I am creating an android game in libgdx engine.My Animation object and rendering code is as
rightAnim=new Animation(0.02f, rightRegions);
rightAnim.setPlayMode(Animation.LOOP_RANDOM);
//Rendering
batcher.draw(rightAnim.getKeyFrame(runTime,true),hero.getX(),hero.getY(),hero.getWidth(),hero.getHeight());
I can see this animation running only on "LOOP_RANDOM" mode, but I want it to play normal loop.In other loop only 1st frame is drawn for eg. in "LOOP_REVERSED" mode only last frame is drawn.I googled 2 days but couldn't find solution.Please help me out and sorry for my bad English .
This:
rightAnim.setPlayMode(Animation.LOOP)
is the correct play mode for a standard animatin loop, and should give you the behavior you want. If that is not working, something is probably wrong with the time ranges you are using.
Try increasing the frameDuration argument from 0.02 to 0.20 and see if you can at least see your animation play through correctly (if slowly).
Also, make sure your rightRegions list is correct.
Finally, what is your code for updating runTime? Make sure that is changing correctly.

Categories

Resources