Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - froz

Pages: 1 ... 12 13 14 15 16 17
196
Ask a Question / Re: Ballistics / Curves
« on: June 19, 2012, 01:47:18 am »
Oh, I'm sorry, I forgot that velocity takes degrees, not coordinates. In such case you would have to calculate angle (using atan2), something like this:

Code: [Select]
atan2[([y of enemy] - [absolute value of ([x of self] - [x of enemy]) - [y of self]) ([x of enemy] - [x of enemy])]
meaning - it takes distance in x and distance in y and decrement y by the absolute value of distance in x.

This may indeed need more time to calculate. How do you calculate bullets motion currently (I mean without the curve)?

197
Ask a Question / Re: Ballistics / Curves
« on: June 18, 2012, 01:47:16 pm »
Yes, though I'm assuming he already need to do that (otherwise bullet could miss moving target). Ofcourse the code I wrote could take little bit more time to process.

198
But why can't you make the text graphics the same size as the card graphic? Then you could just rotate it together with the card. No calculations needed, not problems. Seriously, it's just much easier.

But if you really insist, here is how I do it:

when creating actors (in your case text actors),
- calculate angle and distance from center of the card to the center coordinates of actor
- transfer those values to attributes in your text actor behaviour

in the text actor behaviour create custom event, like this:

Code: [Select]
move [self] to match card turned to [degrees]
{
set x to ((x-center of card + ([cos [(angle from center + [degrees]) as radians]] * distance to center)) - half-width of self) for self
set x to ((x-center of card + ([cos [(angle from center + [degrees]) as radians]] * distance to center)) - half-height of self) for self
point self to [degrees]

Then in your card behaviour, after rotating card put
Code: [Select]
move [text actor] to match card turned to [direction of self]

199
Can you make text graphic same size as the background graphic? Ofcourse everything but the text would have to be transparent.

I know another way to do this, but doing what I just wrote is much simpler, easy and faster. The other way requires calculating text actors positions when the card is turning, based on the base angle from center point of the card to the text actor and the direction of the card actor.

Write if you really can't use the graphic-resizing way.

Edit: I'm only talking about text as graphics, as you mentioned in the first post. I have no idea if it is possible to rotate text written by "draw text" blocks.

200
Ask a Question / Re: Ballistics / Curves
« on: June 18, 2012, 12:52:27 pm »
I'm not sure if it would work, but I just thought of something you could try.

In the update event for bullet, set it's velocity towards [x of enemy], and ([y of enemy] - [absolute value of ([x of self] - [x of enemy])].

What I think it will achieve - at start the bullet will go higher then enemy is, then it will gradually set bullet movement direction lower and lower, untill it hits enemy. The biggest curve (45 starting degree) will be when enemy has the same y value as your tower. There will be no curve if enemy has the same x value as your tower (meaning it's straight below or on top of tower).

Since it would update every tick, it should create smooth curve.

201
Quote
The top one is the collision behavior attached to the player's bullets (the enemy goo balls have a nearly identical behavior). Also enemies have a separate behavior that detects if the colliding actor was an energy bullet, and triggers their death if it is.

I have no idea if it would change anything, but you don't have to do separate when collide events for bullets and enemies. Just add "kill (or recycle) other actor" in the bullet event.

Another thing - the collision will still happen more then once during 0.33 second after the first collision (the bullet will still be alive then). You can add a boolean, run the code only if it's false and set it to true in the code. You can read more about this problem in this blog article:

http://www.thestencylblog.com/2012/06/16/stencyl-events-do-please/

202
Old Questions (from 1.x/2.x) / Re: Behavior problems........
« on: June 18, 2012, 08:02:02 am »
I assumed that this behaviour was scene behaviour, not actor's. But it doesn't really matter, you can do it in actor behaviour.

You can use "self" when poiting to the actor that this behaviour is attached to and you have to identify the other actor and put it to attribute of this behaviour.

You can add one behaviour to many actor types, but only when you want them to do the same thing. In this case you don't want actor B type to do the same thing Actor A type does, so you need to attach the behaviour only to one of those actor types.


I really recommend you doing both crash course tutorials if you haven't and then TD tutorial. It is really, really helpfull as it shows the way how stencyl works. It's usefull even if you don't want to make a TD game. You can find it here:

http://community.stencyl.com/index.php/topic,9984.0.html

203
Old Questions (from 1.x/2.x) / Re: Behavior problems........
« on: June 18, 2012, 07:16:34 am »
Keep in mind that there could be many actors of one type. You cannot just tell a behaviour to do something with actors without anything to point that specific actors.

Do you plan to have many actors A and actors B or just one of each?

The behaviour you posted is a scene behaviour? How do you create actors A and B? If you create them in the scene behaviour, you could create actor attribute for each of them, using "last created actor" just after the creation.

For example:

Code: [Select]
create actor "your actor type" at whatever coordinates
set "Actor A" (this is the attribute you have to create, it's type has to be actor) to last created actor

This way this behaviour will remember the actor it created as Actor A. You can do the same with Actor B.

Then when you do anything with those actors, you can use the attributes Actor A and Actor B.

You can also set this attributes from other behaviours (using "for scene, set _ to _ in behaviour _" block).

204
Old Questions (from 1.x/2.x) / Re: Behavior problems........
« on: June 18, 2012, 05:37:53 am »
You have 3 actors in that code (passive actor, active actor and passive actor 1). Why? Which one of them is your actor A and which one is actor B?

Edit: Actually there is also active actor 1. I'm confused now, but maybe I am just missing something.

205
Resolved Questions / Re: Why wont my Actor get recycled?
« on: June 18, 2012, 01:31:04 am »
First, you don't want to kill and recycle at the same time. You should only recycle recycled actors and kill normal actors.

Second, you are killing and recycling the actor that launches the ball, not the ball. You should move the recycling part into the ball's behaviour or you can leave it here (if this actor will stay alive as long as there is any ball alive), but then you have to change "recycle self" to "recycle the actor". The actor in this case is that blue block you can drag and drop from "when ball exits screen - the actor" block. It means that the actor is always the ball that exits screen (in this particular example).

206
Hmm, have you tried something like this?

Code: [Select]
when created
set n to 0

when key pressed
create actor whatever at "get item n from list x", "get item n from list y"
increment n by 1

207
Ask a Question / Re: Why can direction of self be over 360?
« on: June 17, 2012, 02:22:24 pm »
@coleislazy - well, yeah, that's what I wrote in the first post :). Stencyl has a block for that (remainder of _).
I was just thinking if I missed a simpler way to transform it to -180 - 180 range. Anyway, thanks for help, I have managed to fix my code.

@Hectate: yes, I imagine now that it can be used like this, but for me it was not intuitive. I thought one would have to measure flips manually, but direction would always be just direction, like in real world. Normally you can't have direction of 500 degrees to something, it would always be 140 (or 220).

Nevermind though, I wouldn't even write about it if I wasn't so upset after wasting several hours because I didn't know about it.

208
Ask a Question / Re: Why can direction of self be over 360?
« on: June 17, 2012, 09:50:48 am »
Nope, "as degrees" seems to simply multiply it (like when converting from radians to degrees).

209
Ask a Question / Re: Why can direction of self be over 360?
« on: June 17, 2012, 04:45:19 am »
Thanks for the hint, I'll check that later.

210
Ask a Question / Re: Why can direction of self be over 360?
« on: June 16, 2012, 03:59:24 pm »
Well, maybe, but when I get direction (to compare it to other angles) it isn't converted. I was really suprised to see this.

Pages: 1 ... 12 13 14 15 16 17