LimeJS animation.Sequence does not complete - loops

i have got a probling concerning my animation.Sqeuence.
Only the first Sequence Element is being executed. The 2nd is ignored.
I want the Sprite spell_1 to move to the Hero (hero_x_exact,hero_y_exact), and after that to the destination.
Each element works fine for itself but not in a Sequence.
goog.require('lime.animation.Sequence');
...
var spellmovement = new lime.animation.Sequence(
spell_1.runAction(new lime.animation.MoveTo(hero_x_exact,hero_y_exact).setDuration(1).enableOptimizations()),
spell_1.runAction(new lime.animation.MoveTo(target_coord_x_spell,target_coord_y_spell).setDuration(1).enableOptimizations())
);

What might work better is using a spritesheet with each animation on the spritesheet Then you can build something that loads each animation by name. Obj_Walk001.png, Obj_Walk002.png
Then create a method to read each animation per frame in the scheduling manager.
You can find an example of this code in limejs/lime/demos/test. Then goto run.htm and click on Frame4 this one will show you how limejs is going it.

Related

How to Loop a script in gamemaker

cantSee = collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true)
canSee = !(collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true))
Define the loop as the following:
if cantSee {
cantSeeTimer = cantSeeTimer +1
}
if cantSeeTimer >60 {
speed=0
stopped=true
} else {
mp_potential_step(obj_player.x,obj_player.y,5,false)
}
}
if stopped=true && canSee {
mp_potential_step(obj_player.x,obj_player.y,5,false)
loop()
}
I know the language is bad, but I just want to create a loop command to summon at will.
Thanks, Finn.
so you haven't specified which object in your game currently has this code but it shouldn't matter too much.
So in Game Maker or Game Maker Studio there are a series of events an object can have and one of them is called a "Step" event. A step event is basically a loop that will cycle the amount of times the room speed is per second. Eg: If the room speed of a room is 30 the step event will loop 30 times per second.
I think I can see what you are trying to do and I think I have a solution for you.
Since you can write GML code I am going to assume you understand how to use the GMS or GM IDE.
We want to create a new object called obj_control (or you can choose a custom name). Also don't give this object a sprite as we don't want the player to see it.
Now we want to add an event to our new object so make sure you still have the windows for obj_control (or whatever u called it open). and click on the 'Add Event button' shown in this image: http://imgur.com/A7szwFO
Once you click on it, click on 'Step'. http://imgur.com/s0ksiyD
Now select 'Step' again. ('Begin Step' and 'End Step' don't do what we want so let's just ignore them)
Now we need to add your code to the step event we just created. So make sure you are on the 'Control' tab and find the script editor (you should know where to find it) and drag one into the 'Actions' for the step event.
http://imgur.com/de3gE01
Now a script editor should pop up automatically but if it doesn't just double click the "Execute piece of code". Now we just need to copy and paste all of your code into the script editor.
http://imgur.com/sNBOCFu
Now click on the green tick on the top left corner of the window to save the code.
Now before we are done let's make sure we define the variables in a create event. So make a create event and add this code:
cantSee = collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true)
canSee = !(collision_line(x,y,obj_player.x,obj_player.y,obj_corner,false,true))
After you have added that create event and inserted that code into it save all changes to the object.
All that is left is to add this object we created to every room of the game so it can function.
Hopefully this helped and if it didn't just let me know and we can get it sorted.

ActionScript 2 - Get MovieClips' initial position and save it for each mc for later target position

I am working on an animation in AS2 which requires that all text MovieClips (instance names starting with "txt_") will be manually placed initially on stage and I need to store their own initial placed positions (x,y) so they will be retrievable later when I want to animate them to these same final coordinates regardless of where they move around in the meantime.
So the following steps needed:
All these text movieclips are placed on stage manually from library (not dynamically) matching their expected target keyframe end position (x,y) to get desired final screen layout.
Then a frame script loops through all these MovieClip instances on stage before rendering them on stage and stores their initial (also future target) (mc.targetPosX or mc.targetPosY) positions.
Then frame script also moves all of these MovieClip instances before rendering them on stage and moves/offsets them elsewhere on stage (eg. mc._x +=25px;) and hides them (eg. mc._alpha =0;)
Finally by using a tween like Greensock I want to use their stored target end position to animate each of them to their stored final target position.
(eg. TweenLite.to(mc, 1,{_alpha:100, _x:mc.targetPosX, ease:Quad.easeOut});)
I was able to create a loop to get "txt_" movieclips but then I don't know how to save their target positions with their instance and use them outside the loop afterwards.
Thank you in advance,
Attila
I don't know what problems do you have trying store some variables inside instances, but here my suggestions about proccess you described.
First of all we have loop which do all thing you described at question.
To do so we must have some list of you mc's or pattern to make this list dynamically. From you question i suppose that you use this kind of loop.
for(var i=0, txtCount=10; i<txtCount; i++){
textMc = this['txt_'+i];
//do stuff
...
}
From here on your points.
You already did it.
Use loop described above to store current object properties inside his instance
textMc.storedX=textMc._x;
textMc.storedY=textMc._y;
Here is same loop place object wherever you like
textMc._x+=25;
textMc._alpha=0;
Finally right after that in the same loop use greensock.
TweenLite.to(textMc, 1,{_alpha:100, _x:mc.storedX, ease:Quad.easeOut});
That's it.

Esri Silverlight control Pan/Zoom from code

I have trouble getting Map behave properly when calling ZoomToResolution and PanTo
I need to be able to Zoom into specific coordinate and center map.
The only way I got it working is by removing animations:
this.MapControl.ZoomDuration = new TimeSpan(0);
this.MapControl.PanDuration = new TimeSpan(0);
Otherwise if I make call like this:
control.MapControl.ZoomToResolution(ZoomLevel);
control.MapControl.PanTo(MapPoint());
It does one or another (i.e. pan or zoom, but not both). If (after animation) I call this code second time (map already zoomed or panned to needed position/level) - it does second part.
Tried this:
control.MapControl.ZoomToResolution(ZoomLevel, MapPoint());
Same issue, internally it calls above commands
So, my only workaround right now is to set Zoom/Pan duration to 0. And it makes for bad UX when using mouse.
I also tried something like this:
this.MapControl.ZoomDuration = new TimeSpan(0);
this.MapControl.PanDuration = new TimeSpan(0);
control.MapControl.ZoomToResolution(ZoomLevel);
control.MapControl.PanTo(MapPoint());
this.MapControl.ZoomDuration = new TimeSpan(750);
this.MapControl.PanDuration = new TimeSpan(750);
Which seems to be working, but then mouse interaction becomes "crazy". Mouse scroll will make map jump and zoom to random places.
Is there known solution?
The problem is the second operation replaces the previous one. You would have to wait for one to complete before starting the next one. But that probably doesn't give the effect you want.
Instead zoom to an extent, and you'll get the desired behavior. If you don't have the extent but only center and resolution, you can create one using the following:
var zoomToExtent = new Envelope(point.X - resolution * MapControl.ActualWidth/2, point.Y, point.X + resolution * MapControl.ActualWidth/2, point.Y);
Btw it's a little confusing in your code that you call your resolution "ZoomLevel". I assume this is a map resolution, and not a level number right? The esri map control doesn't deal with service-specific levels, but is agnostic to the data's levels and uses a more generic "units per pixels" resolution value.

How to add next and previous buttons in matlab?

We create a matlab gui for registration.In that form we have to see each images from an array on the buttons clicks. we need to be implement two pushbuttons ie 'next' and 'previous'. when we click previous we have to see previous image on the axis and vice versa. plz help us. Thank you in advance.
Well, the steps are pretty straightforward:
In your GUI's OpeningFcn you should add code to load the images from the folder:
create a cell array filed in handles, e.g. handles.img_store;
load images one by one in handles.img_store{:} using imread();
create a current image index, e.g. handles.img_index, and initialize it to 1;
display the current image using display_current_image() function—see 4.;
Write the callback for the pushbutton "Next" to increment handles.img_index, reset it to previous value if it goes out of bounds of handles.img_store, then call display_current_image()—see 4.;
Write the callback for the pushbutton "Previous" to decrement handles.img_index, reset it to previous value if it goes out of bounds of handles.img_store, then call display_current_image() function—see 4.;
Create a function, e.g. display_current_image() that will take handles as argument and, using the image() function, displays the image with the index handles.img_index in the cell array handles.img_store
I will not write code, not until you try to write some code first. :-)

Show progress bar when sending pages to the printer (WPF)

I am creating printouts in WPF using flow documents. These printouts are set in separate window where DocumentViewer is placed.
When user clicks print I would like to show a progress bar that informs about current page that is sending to the printer. How can I do this?
I'm not sure exactly where your print code is, or where you want the progress bar, but I did something similar to this recently. This will be in VB.net.
First of all, create a new progressbar in the same class as the code you use to send the page to the printer. Then, we're going to take advantage of the "top-down" order in a block of code to change the progress bar.
The progress bar's value should be set to "0" be default. Now, in the code for sending the page to the printer, you're going to increase the progressbar's value (such as with the code "MyProgressBar.Value = MyProgressBar.Value + 1"). Put this code in between each line of the code you want to show progress for.
I would change the "+ 1" part of the code, however, to another value, so your progress bar progresses equally after each step. If you have three lines of code, then use "+ 33" (100\3), four lines use "+ 25", etc.
Finally, at the end of the code, set "MyProgressBar.Value = 100"
This only works, however, if you have access to a code longer than one line. For one line of code, I'm not sure how this works, unless you can get to the block of code that line points to.
If you have to use code from another class, you may need to do something like...
Dim MyWindowWhereProgressIs As New MyWindowWhereProgressIs
And then, each time you need to change the value, try...
MyWindowWhereProgressIs.MyProgressBar.Value = MyWindowWhereProgressIs.MyProgressBar.Value + 1
I'm not entirely sure whether or not those last two lines of code will work, as I'm away from Visual Studio right now, but it is worth a shot.

Resources