zoom

Non-platform specific questions.

zoom

Postby sportmaster » Wed Nov 24, 2010 12:37 am

What is the code to zoom sprite and to define zoom speed ?
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: zoom

Postby skydereign » Wed Nov 24, 2010 5:50 am

Currently you have to use canvas for this. The code to draw an actor (which you can zoom by changing the scale) is this.
Code: Select all
draw_from("actor", x, y, 1.0);


To zoom in, you would create a variable that holds the current zoom, so just call it zoom. One thing to note is that zoom cannot be an int. Also 0.2 is the speed at which the actor zooms in at.
Code: Select all
zoom+=0.2;
draw_from("actor", x, y, zoom);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: zoom

Postby sportmaster » Wed Nov 24, 2010 4:43 pm

The zoom is working with up and down keys, fine , but there is a problem when zooming out, sprite leaves a weird mark. How can I get rid of this trace ?
Attachments
zoom.rar
take a look at this ok ?
(66.66 KiB) Downloaded 146 times
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: zoom

Postby jimmynewguy » Wed Nov 24, 2010 5:03 pm

get rid of all the draw_from() actions on the keydowns just leave the zoom+ or - and put this in drawactor ->script editor
Code: Select all
erase(0, 0, 0, 1);
draw_from("blow", 320, 228, zoom);
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: zoom

Postby sportmaster » Wed Nov 24, 2010 7:25 pm

That's right, it should be done like this, my zoom is working properly thank you mates :D !
User avatar
sportmaster
 
Posts: 32
Joined: Thu Jun 25, 2009 8:29 pm
Score: 0 Give a positive score

Re: zoom

Postby 247wkman » Sat Aug 03, 2013 9:21 pm

i can't seem to find the post that i downloaded this example ged from.

edit: still can't find this examples post origin (my word searches are rejected as too popular) but playing about with it i'm begining to see it is possible to do what i'm hoping for.
i was being led to believe a canvas's contents could only be registered as a single actor so collisions with any drawn object within it would simply be taken as a collision with canvas as a whole (! wait that probably true i think?)
what i'm driving at is i gave collision events with 'Actor' to 'object' and they did indeed register while being drawn exclusively inside the canvas- and even with actors outside the canvas.
this is great because though i like to make a side scroller some day, i want to have enough environment depth to receed into the background to navigate simple rooms or switch between a strict left/right only in one room to a left/right/up/down ala streets of rage in another with scaleing.

this is a relief as i could only answer this problem by using a separate canvas for each actor i wanted to give scaleing- this would mean leap frogging actor roles in and out of the canvases and just could not do that.

anyone have a link to where this file (new3d) came from? i really want to look and read for additional explanation. its a good example as is zoom, for revealing what i like to see g.e being able to do and confirms it can.
Attachments
New3D.rar
(511.89 KiB) Downloaded 131 times
Last edited by 247wkman on Sun Oct 20, 2013 11:06 pm, edited 1 time in total.
247wkman
 
Posts: 67
Joined: Mon Dec 13, 2010 3:55 pm
Score: 3 Give a positive score

Re: zoom

Postby 247wkman » Sun Aug 04, 2013 11:51 pm

(after many edits)
I GOT THE ZOOM TO WORK FOR A FULLY ANIMATED ACTOR NOW!
the trick is to make a reference to what value you want zoom to represent at each event like this:
in canvas; create event:
zoom=1; //enables the actor's first draw to be true size (or desired size)
erase(0, 0, 0, 1);
draw_from("blow", 320, 228, zoom);

draw event:
erase(0, 0, 0, 1);
draw_from("blow", 320, 228, zoom); // draw will refresh the actor frames so it can maintain continuos animation and specifically, zoom at its LAST referenced value. because zoom has a value reference at 'create event', the actor no longer starts of as the -so small it dosent even exist size, it has a scale of origin now.

add some left/right movement to the canvas (or i guess you could do a left/right-/+=# in the canvas draw code i think- if zoom is anything to go by) and you have a character that can move in 4 or even 8 directions (set a diagonal movement up and half the value change of zoom) moving towards and away from the view.

i set a collision event with the earth so see how it responds (okay i think). using scale up to collide with it, pushes the canvas away and reveals the boundry.

which leads to the next problem: how do i limet the scalling of the sprite? by adding a constraint after the zoom value statement:
in the down key event after: ''zoom+=0.01;'' add: ''if (zoom>2) zoom=2;'' // 2 will keep it from getting larger than twice its size.
in the up key event after: ''zoom-=0.01;'' add: ''if (zoom<0.3) zoom=0.3;'' // if you wonder why i set up to shrink and down to grow; its because i'm thinking in terms of moving a player actor to and from the camera!

additional tweak: distance percieved speed
something bothers me- the actor shrinks faster as it gets smaller and grows slower as it gits bigger. maybe its like when a tablet when its desolving in water. but if your in a car passing pylons/road lamps, you find distant things move towards/away slowly and then as they get closer they speed up and zip passed you; so with this in mind i make this change in the ''up key'' action: zoom-=zoom*0.02;
and ''down key'' action: zoom+=zoom*0.02;
it should multiply zoom by small value; so each multiplication should be larger than the previous one, and if the result is smaller each time then it will shrink slower. (the ''if'' stuff is not relevant here, just playing with the values)


deal with collision into a wall when moving up/down screen? how to create an assotiation between it and z-depth and y position of foot contact to the ground (so that if you move up to a wall, the feet will be level with the base of it when you bump into it- it would be ideal to have a separate actor to sit at the foot of the player as the basis of depth set obsticals. but how to keep it there when the scale of origin is at the centre of the actor... i could double the height of the sprite image- so the charcters feet begin at the halfway point. then can set the draw coordinates to the center of the canvas. the parant/ground collider actor sitting a the feet should remain as such- this would save me figureing out a code that would require refrencing zoom's value [as zoom now has a create size, its size after being scaled up/down is probably attainable somehow now] and telling the grounding actor to move up/down from the canvas center at some given formula- but wouldn't this save more memory than doubling the height of an image sequence?)
Attachments
zoom.character test.rar
(253.74 KiB) Downloaded 147 times
247wkman
 
Posts: 67
Joined: Mon Dec 13, 2010 3:55 pm
Score: 3 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron