Yann's Forum Posts

  • ninjaTurn4.capx

    Somehow, the walking animation was set one tick later. So the turn animation frame 0 was displayed. Very weird. But setting the animation in the state="Walk" subevent make sure you set frame 0 from animation "Walk" and not "Turn". Well look at it you'll see.

  • newt's idea is to sample a value in an unrotated rectangle and then rotate the values arround the center.

    Let see then :

    sample values inside a rectangle :

    x = rectangle.x+random(-rectangle.Width/2,rectangle.Width/2)
    y = rectangle.y+random(-rectangle.Height/2,rectangle.Height/2)

    Then you rotate the value around the center

    xRot = rectangle.x + cos(angle(rectangle.x,rectangle.y,xSample,ySample)+rectangle.angle)*distance(rectangle.x,rectangle.y,xSample,ySample)
    yRot = rectangle.y + sin(angle(rectangle.x,rectangle.y,xSample,ySample)+rectangle.angle)*distance(rectangle.x,rectangle.y,xSample,ySample)

    We can simplify that by sampling the rectangle at 0,0 and then offsetting the restult

    x0 = random(-rectangle.Width/2,rectangle.Width/2)
    y0 = random(-rectangle.Height/2,rectangle.Height/2)

    And then

    xRot = rectangle.x + cos(angle(0,0,x0Sample,y0Sample)+rectangle.angle)*distance(0,0,x0Sample,y0Sample)
    yRot = rectangle.y + sin(angle(0,0,x0Sample,y0Sample)+rectangle.angle)*distance(0,0,x0Sample,y0Sample)

    So basically, sampling a random number in a rectangle is the same as chosing a random angle and distance from the center of this rectangle and applying a rotation.

    In short it will be something like that:

    +On what you want
      Local number randX=0  //random X position withing the rectangle
      Local number randY=0  //random Y position withing the rectangle
      Local number randA=0  //random angle before rotation
      Local number randD=0  //random distance
      -> System: set randX to  random(-rectangle.Width/2,rectangle.Width/2)
      -> System: set randY to  random(-rectangle.Height/2,rectangle.Height/2)
      -> System: set randA to angle(0,0,randX,randY)
      -> System: set randD to distance(0,0,randX,randY)
      -> System: set randX to rectangle.x + cos(randA + rectangle.angle) * randD
      -> System: set randY to rectangle.y + sin(randA + rectangle.angle) * randD

    Should work...

  • hehe sure you know I'm french :D

    I saw it, I was planning to answer with another pic but didn't find the time to do so :D (I'm on rotary mode and bit of rush at work)

  • ok (:

    could help to have at least some visual to be sure but let see

    if you're on :

    • top left (0,0) angle should be 0
    • top right (layoutwidth,0) angle should be 90
    • bottom right (layoutwidth,layoutheight) angle should be 180
    • bottom left (0,layoutheight) angle should be 270

    so then hmmm I see

    +When you want
      -> tiledBg: set position to choose(-1,1),choose(-1,1)
      -> tiledBg: set angle to angle(0,0,self.X,self.Y)+135
      -> tiledBg: set position to clamp(self.X,0,1)*layoutWidth,clamp(self.Y,0,1)*layoutHeight

    should work (:

    Explanation:

    Let's look each of these 3 actions one by one

    1/ basically the first action gives you this kind of possible result:

    (-1,-1)

    (1,-1)

    (1,1)

    (-1,1)

    2/ If you draw these points on a graph you'll notice that angles from origin to these points are multiple of 45...

    But the most important, these 4 possibilities are 90 degrees appart and in a proper order.

    So by adding 135 you end up with somthing like :

    angle(0,0,-1,-1)=-135 -> -135 + 135 = 0

    angle(0,0,1,-1)=-45   -> -45 + 135 = 90

    angle(0,0,1,1)=45    -> 45 + 135 = 180

    angle(0,0,-1,1)=135   -> 135 + 135 = 270

    3/ And then if you clamp at min 0 max 1 these kind of value you end up with

    (0,0)

    (1,0)

    (1,1)

    (0,1)

    you then just have to multiply these value by (layoutWidth,layoutHeight)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • why don't you put the hotspot of the tiledbg in the middle and just do a

    set angle to floor(random(4))*90 ?

  • Basically this question leads two different answers to my knowledges :

    1/ Either, as Tasty did, you use c2 as a level editor & game engine. So each layout is a level and you associate or include your event sheet engines.

    Advantages:

    • you don't have to create a level editor
    • you have an unlimited level of tweaking

    Disadvantages:

    • creating a level can take a bit more time and you can make mistakes
    • maintaining a level is a pain if you want to add new stuff (like a particle fx to makes things cuter) you have to add them on all your level or use the global trick.

    2/ Or you use one only game layout, but you create your own level editor.

    Advantages:

    • creating level is easier as you made the level editor to speed up the process
    • you can make dramatic changes in UI or in-game Looks in no time
    • you avoid the too-much-layout hell

    Disadvantages:

    • you have to create your own level editor. Which isn't super hard but need time. The only good thing about that is that if you don't release it publicly you can make crappy UI and just put what you need. You will probably be the only one to know how it works :D
    • you have a bit less freedom once you created your data format so you have to think this through:

    ----what infos do you store?

    most of the time: position,angle,scale,opacity and type of object

    ----how do you store them?

    CSV format seems at the moment the only practical way in c2 (no xml parser or binary array loader as far as I know)

    ----how do you recreate the level?

    I usually spawn the same object sprite in which I put different animation according to the "type of object" stored.

    If we could access family members by indexes that could simplify this process a bit by not having all objects in one sprite. (thus separating behaviors and instance variables) Would need an ordering feature in the family manager though.

    Hope Ashley will think about that (:

  • event 5 should be something like

    "Publish score myScore"

    where 'myScore' would be the global number you use to keep track of score during the game

    I never made any facebook game so I can't be sure but, to me, that's the only weird part of your code.

  • event 5 -> "Publish score 0" ?? o_o

  • global number x = [insert the starting X position]
    global number y = [insert the starting Y position]
    On start of frame
      -> player: set X to x
      -> player: set Y to y
    On entering a bulding
      -> set x to player.x
      -> set y to player.y
      -> go to layout building
  • fadeBug.capx

    you were restarting the fade every tick while the mouse was over the column, so it got stuck at the start of the fading

  • capx

    capx for touch

    You can set min and max value in instance variable of sld_line object.

    As well as a snapped boolean if you want your slider to snap on rounded values.

    The sliders now use container to associate the button, the line and the eventual textbox object.

  • if you read it,

    if background = 0 set background to 1

    and then event 3 is true and it goes back to 0

    So both event happens.

    Also local variable are reset to there default value every time you read the subevent part they are into.

    Your solution is to use a global variable, not a local. Just drag the declaration just before event 1.

    And then event 1 before your subevents just do a

    System: set background to 1-background

    It will toggle between 0 and 1

  • fun to do

    animatedGradient.capx

  • In your attempt you don't filter specific instances of ObjectB

    so the distance check will be true as soon as there's an ObjectB close...

    Also System expression doesn't filter the SOL.

    So it will change all the overlap variable of all instances of ObjectB

  • +System: every tick
      -> ObjectB: set Overlap to 0
    +System: foreach ObjectB
      +System: foreach ObjectA
        Local variable else = 1
        +System: distance(ObjectA.X,ObjectA.Y,ObjectB.X,ObjectB.Y <= 300)
          ->ObjectB: Add 1 to Overlap
          ->System: set else to 0
        +System: else = 1
        +ObjectA is overlaping Radius
          ->ObjectB: Add 1 to Overlap[/code:14n7r9sb]
    
    There's only one issue
    The radius sprite... how do you associate it to each ObjectB ?