Baked's Forum Posts

  • 15 posts
  • Brilliant, that's exactly what I wanted. Thankyou :)

  • Hi,

    I want to perform some actions on touched but not when a specific object is touched.

    I can't invert the on touched object. Is there a work-around or different way to achieve this event?

    Thanks

  • game will do an alert if it can't find at least one instance in layout, so yes, you must have at least one instance of every sprite created NOT by events. I think a quite good solution would be to create a layout with all game sprites, and never go to that layout if you cannot bare having instances outside standard layouts and destroying them on start :)

    as for onCreated - well create object event triggers on created - that's obvious. already created objects are not created during the game, they are there from the beginning - that's why the oncreated doesnt trigger I think.

    hope that helps

    Yes, I use the same technique placing all objects in an unused layout.

    As for onCreated; technically the instance of the object must be created when that layout loads the objects you placed in the designer.

    Anyway, I've just joined the onCreated and layoutStart events with an 'or' as that seemed like the most elegant solution.

    Thanks again.

  • Thanks guys, I will have a look at those solutions.

    But am I the only one that thinks the object created event should be called for each object that is already in the editor?

  • Use 'on start of layout'?

    Objects can be created during gameplay as well as present at the beginning. So I would rather not duplicate actions.

    Surely it makes sense for an objects Created event to be called if it 'created' when the layout starts?

  • Is the On created event only fired when you create an object through an action? Doesn't seem to be working on objects that are already placed in the layout.

    Is there a workaround for this?

    Thanks

  • Nope this isn't really what I am looking for. Maybe you've misunderstood me.

    Think angrybirds, the way you have different types of birds in a set order for each level. Once one has been used up the next one spawns. I need something similar to that system.

    Cheers.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is similar to the solution I am currently working on. The part I'm having difficulty with is deciding which object to spawn.

    Would using an array to store which objects and what order to spawn them in be the best solution here?

  • I need to spawn different types of objects in a certain order for each level.

    What type of system can I use to control this and how can I decide what type of object to spawn?

    Thanks

  • To calculate an objects angle of motion, create 2 instance variables for the object called 'PreviousX' and PreviousY'

    at the end of your events add

    Every Tick -> Object: Set PreviousX to X

                  Object: Set PreviousY to Y

    Then to calculate the objects actual angle of motion use Angle(Object.PreviousX,Object.PreviousY,Object.X,Object.Y)

  • SOLVED

    The problem was GravityPhysics is a family behavior, so it seemed to be getting the wrong velocity values so I used superkews solution using instance variables instead of globals.

    If anyone knows how to target the correct instance of that behavior I would be very greatful.

    Cheers

  • hmmmm,

    I might have just rushed to answer your post :)

    But, remember that the point 0,0 is the top left corner of your screen. So you are continuously calculating the angle from there.

    VelocityX should be the magnitude of the velocity in that direction, as with VelocityY. Calculating an angle based on the origin (top left corner) and the magnitude of the velocity is sure to cause some strange results isn't it?

    As I understand it:

    The velocity is just a coordinate position relative to the current position. It can be negative.

    So the position of an object in the next step using velocity is just x+Vx, y+Vy. So if you calculate the angle from 0,0 using Vx and Vy is should be the correct direction?

  • can you please save it as a .capx? in a caproj file, the sprites are not included.

    I think, the image is just facing the wrong position, but I can only tell for sure, when you provide a .capx

    EDIT: Made an example of a sprite that always faces into direction of movement. Link

    Updated my project file for you.

    And I can't oipen yours as its version is newer than mine. I thought I had the most recent version though? :/

  • here is what you need:

    Global variables

    int PrevX;

    int PrevY;

    On Every Tick:

    {

    Set angle to the angle between the current X and Y, and the Previous X and Y

    Set PrevX = CurrentX;

    Set PrevY = CurrentY;

    }

    Won't those global variables be overwriten since I have more than one instance of an object?

    Also isn't the angle between previous and current X,Y exactly the same as velocity X,Y?

  • Hi,

    I have multiple instances of a Sprite with the physics behavior flying around my screen.

    I just want the sprite to face the direction it is travelling in.

    I have tried setting angle of the object to Angle(0,0,Object.Physics.VelocityX,Object.Physics.velocityY) in the Every tick event. I have also tried similar with a For each Object in the Every Tick event.

    Results can be seen in the project file, seems weird to me.

    Project (just click to fire object)

    Any help or suggestions is appreciated,

    Thanks

  • 15 posts