Jhonathan Ibanez's Forum Posts

  • heheheh xD!!. Man thank you, that plugin is exactly what I was looking for :)

  • Yeah I mean something like...

    function SpawnByName(name,layer,imgpt){

    var obj = name.type; //I know there is not property that would allow me to //do this but I do know there is a runtime.type_by_index property that I //can use and that there is a certain property type.index that would come //in handy too for this

    var ins = this.runtime.createInstance(obj, layer, this.getImagePoint(imgpt, true), this.getImagePoint(imgpt, false));

    /*

    ...

    ...

    ..

    */

    }

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi everyone.

    As you could guess I am trying to implement an Action that I may use to Spawn an instance of a given type by its name. I am not sure if this kind of action would be a bad practice but if not (or even if is I would like to know if there is a way I can create an instance through its name just our of curiosity) I need to know how could I get the type of a given Object in the runtime.js. Thank you before hand.

  • Hi Hillstrom. That will definitely come in handy :). If you want I can try and create a Manual :). For now what I did, as I mentionated earier, was to implement a B?zier Curve.

    This is my function: 107*((1-EnemyShip.Speed)^2)+2*(1-EnemyShip.Speed)*EnemyShip.Speed*520+(EnemyShip.Speed^2*Sprite3.X)

    It is messy so I do not expect you to understand it nor use it, but if you ttake the time to look closer at it, and you look at this link :http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/, you will understand how you could implement this kind of movement. BTW, I used set X, Y instead of "move to object" or other behaviours actions. Right now my function is cuadratic and so it is not quite a circular movement, I am working on the cubic version of this functions.

  • Hi GeneratorX. Thank you for answering, You solution seems fairly good, however, would I need to "hardcode" those points?. In the other hand (and because I didn?t want to sound rude with GeneratorX), I managed to create the kingdom rush movement using Bezier curves which turned out to be quite easy to implement, if anybody needs it I could create a tutorial, just let me know.

  • Hillstrom: You can ask whatever you want, I do not mind. I can answer you this from a programming perspective. I do not think that having a sprite with animations that make the illusion of various troops would be a bad practice, nor having separate sprites for every single unit is either. It is less memory expensive to use a single sprite for an entire or part of a troop, of course, but what really matters is the kind of game you want to create. If your game would gain no extra benefit from having every single unit with its own sprite then just don�t do it. For example, if your game is going to implement a "power" that kills a single unit, not matter how much HP or whatever it has, then the single sprite troop approach is not an option, in the other hand if your game is not going to implement such specific mechanics, and maybe you are going to spawn a fixed number of troops (like in Lord of the rings battle for middle earth), then that approach would be correct. Hope it helps.

  • Paradox: Thank you. I took a look at pathfind cost and as you say it might help but at least I was not able to make it work, so I am going to try darklinki�s option, thanks again though.

    Darklinki: I would definitely thank you if you could make an example for me (I had a hunch about pathfinding not being the answer to my problem).

  • Thank you very much for you quick reply. Unfortunately it seems like I cannot figure out how I could use the RTS sample to achieve my goal... I can?t make my troops move along a fixed path, is there a way to make my troops march througn an object. Say I have a road image, I create a sprite object and put the my road image for that object, could I make my troops move through that object?

  • Hi guys.

    My problem is, as the name of the topic suggest, that I would like my troops to move along a fixed path like those of kingdom rush.

    I am aware of the pathfinding behaviour, I have tried plenty of things with this behaviour but with no succes until now. Any help would be appreciated.

  • Hi everybody.

    As I expected, it worked!!. It was pretty simple to solve (silly me...), I do not know if all of you guys who might have read this topic are saying "gosh that is so simple, this guy is just so noob", but if you dont, and in the other hand you have the same problem I had, please tell and I ll create some tutorial or something.

    Anyway, I managed to solve the problem of angle facing with senital frames animations (so my game could have some kind of a senital perspective of course), and without losing the predictive aim features of turret behaviour by dividing the logic of turret behaviour from the sprite animation, in other words, I created a dummy object (sprite object) that will be actually implementing the turret behaviour with no sprite at all (so it looks invisible and I know I can make it visible/unvisible with a property) and another object that will have the actual turret sprite. When you do that, the golem wont rotate (while the actual turret will) and it will look like the golem is shooting to the desired direction but with no funny rotating animation.

    I could add more details but I think that it would be better understood with a tutorial, so please, let me know!. Thank you everybody.

  • I think the solution to my problem is actually pretty simple, Ill try something I just come up with a minutes ago this night, and if it works, I ll let all of you guys know. Wish me luck :P.

  • Well I managed to somehow trick that, and that is not the problem.

    Trick: if this could be called a trick..., what I did was to put another object called AbstractTurret (not the best name, I know) but without a sprite on it so it is "invisible", on top of the actual turret sprite (golem), this is rotating and using the turret behaviour, that way I use the predictive aim feature.

    The problem is that I want the actual golem sprite to "face" the enemy (sprite animation that is only played, frame by frame, if the enemy is on range) according to the angle formed between the two of them (golem and enemy).

    Note: I do not know yet if my "trick" I the worst practice ever!, but it works, I looks like the golem is actually shooting, looks nice, and logically filled my needs. If this approach is not criticized may be I ll create a manual (do not know if this is worth it, but could come in handy for some guys as lazy as me :P and who do not want to write some code even if programmers like myself xD)

    Again, I apologize for my english :S :P.

  • Something I did not mention is that I do not want to use the rotation of the turret behaviour, this is because even though I want to take advantage of features like: Predictive Aim, On shoot, etc. I want my game to have a senital perspective, so allowing my turret sprites to rotate would have a funny look on them and that is not what I want.

  • Thank you for your reply, I�ll take a look at that :).

  • Hi everybody, I�ll try and go straight to my problem.

    A bit of context: I have a golem turret object (it is a sprite object, it has turret behaviour). These golem turrets appear when I click in the screen (for now). These turrets shoot rocks at the enemy (sprite object) which appers randomly in the screen and takes a journey toward a randomly defined path (pathfinding).

    Objective: the golem "faces" the enemy it is shooting at depending on the position of the enemy (if we center our origin point at the current position of the tower then, if the enemy forms a 45 degrees angle with its position and that of the turret, and we assume clockwise angle as usual, then the golem faces front-right)

    Note: I already have the frames to simulate the golem facing.

    Problem: when I use the angle function (my golems have an instance variable named "Aim" which registers the angle formed between the position of the enemy and the golem), lots of enemies appear and lots of golems are placed, the golem seems to be unable to "choose" wich enemy "forms" the angle and won�t change its frame to simulate the facing behaviour.

    Note: I already tried something like:

    System every tick

    golem has target -> golem Aim set value angle(enemy.x,enemy.y,golem.x,golem.y)

    [sub event]

    //logic to change frame depending on the angle formed

    Sorry about my english, I know it is not the best. Any help would be appreciated.