naval battle

0 favourites
  • 7 posts
From the Asset Store
Strengthen your battle experiences with these 4 frantic, epic and intense battle music tracks!
  • hey working on my shipbattle system :)

    i got some problems,

    basicly is want to know if my ship should shoot left or right or both

    i had something going but it doesnt work for multiple ships

    i was thinking of using pickedcount and is clockwise or not, so when there

    nr of ships is clockwise, enable right shooting

    nr of ships is counterclock enable left shooting

    but it doesnt work

    by the way, should pickedcount not give a -1 or something if nothing is picked, its not very usefull like this

    i prepared a cap for testing, so if somebody wants to help, cause im hitting a wall here <img src="smileys/smiley5.gif" border="0" align="middle">

    http://dl.dropbox.com/u/61666915/navalbattle2.capx

  • is it hard to do maybe? any idea's?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • don't have a solution for you, but I think I'm having the same sort of problem, and i think it's due to me not understanding picking instances very well

    anyway, here's what i would like to do:

    1) generate a random amount of enemies on the screen in random positions (i've been able to do that much!)

    2) i want to be able to recognize what side of the player sprite the enemies are (this is where i'm getting tripped up);

       

       if i manually create a single instance of the enemy sprite and place it on the view area myself, it seems to work

       I was thinking if i go through an 'every instance of enemy sprite' loop and check if it's clockwise or counterclockwise from the player sprite it would work but nope!

    anyway, here's the capx -

    dl.dropbox.com/u/62693846/WhatSideAmIOn.capx

    hope somebody can help

    thanks

  • rojohound very nice, thank you!

  • rojohound

    thanks for quickfix, but I do have to ask... HUH!

    i can see it working, but logically i don't get it, why wouldn't my way of looping through each instance of sprite not work,

    or in other words why do you need to create a new instance variable just to assign it a UID that's created automatically anyway

  • heater19

    Yeah... I agree I left out my my logic for the fix, which makes it not very helpful. So here's my trail of thought:

    Events 5-7 in your original capx only filtered the "Sprite" object. "Sprite2" is unfiltered and only the first instance of "Sprite2" is used in the expressions. "Text" is also not filtered. So it runs like this:

    if "Sprite" is CW from the first "Sprite2" then set all the "Text" objects' text to 'Left'.
    if "Sprite" is CCW from the first "Sprite2" then set all the "Text" objects' text to 'Right'.

    Relevant section of manual: http://www.scirra.com/manual/75/how-events-work

    So there are two problems.

    1. Only the first "Sprite2" is being compared against. Changing "Every tick" to "for each Sprite2" in event 5 fixes that.

    2. All the "Text" objects are getting set to the same value. What is needed is a way to be able to pick the "Text" that's paired with "Sprite2". Unfortunately he pin behavior doesn't cause the pinned objects to be picked, so some other method needs to be used.

    I like using a instance variable to store the UID of another object, so that the paired object can be picked at any time with "pick by UID", but that is not the only solution. You could alternatively use

    Text|Pick nearest to (Sprite2.X, Sprite2.Y)

    or

    System|pick Text instance Sprite2.IID

    and you would avoid the need for an additional variable.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)