PixelRebirth's Recent Forum Activity

  • it's just as simple without custom movement,

    crosshair | set x to self.x + Xaxis*speed*dt

    crosshair | set y to self.y + Yaxis*speed*dt

    Agreed. I'm merely suggesting custom movement for handier expansion of the movement, since the behavior provides useful expressions, conditions and actions. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • bilgekaan Basically there isn't really much difference between my version and yours.

    Apart from the things I mentioned I did also only allow the game itself to load when the API was ready. However this isn't even a requirement for this particular API, so you can neglect that part.

    I almost overlooked earlier that skyhunter93 used a local version of the API script file to go with the plugin. This might work fine, however in the API documentation it states that you should include the script from the provided URL.

    Technically this does not comply with the requirements of the API anymore. Maybe it won't matter after all. Skyhunter93 should know soon. <img src="smileys/smiley17.gif" border="0" align="middle" />

  • An easy way to control a sprite with the analog stick of a gamepad would be to add the custom movement behavior to the relevant object.

    Then set its horizontal speed according to the X axis of the right analog stick with the expression "Gamepad(0,2)" and the vertical speed according to the Y axis with "Gamepad(0,3)".

    These expressions return a range from -100 to 100, so you should multiply here with the maximum speed value of your object. Also dont forget delta time "dt"!

  • Executing strings with the Browser object is an ugly hack. If you want to do it properly, use the Javascript SDK.

    Can't say I'm that much into cosmetics. So I wouldn't really care if something was "ugly", as long as it worked of course. <img src="smileys/smiley1.gif" border="0" align="middle">

    But seriously it seems to me that making a plugin just to use one javascript method or two is a little bit of an overkill.

    Would you care to elaborate briefly why you deem it a bad idea to use the execute javascript action/ expression of the browser object? Are there possible issues people don't usually consider?

  • I'm making a example capx right now but in the meantime:

    Here's a little plugin I made:

    https://www.dropbox.com/s/nuf5zq2dv3jwtgt/spilgames.zip

    The only thing it does is adding the spilgames API to the index.html so you don't have to add it manually each time you export your project. It's a huge time saver.

    I talked with spilgames and they said that the ads are not showing right now because their API isn't complete right now and are testing things. So there is no way for us to test it right now. I suppose they use a local environment on their side to test the ads.

    Actually my implementation is pretty similar to the one bilgekaan did. but you are now seeing the ads because of what I said.

    Ah, so the ads don't show on localhost as I suspected. This leads me to believe that bilgekaan's implementation and mine would also work fine.

    If you're worried about having to alter the index.html each time, you could simply keep a second already altered index file around, called index2.html so it won't get overwritten.

    Just don't forget to use the altered one and rename it back to index.html when you're submitting your game.

    If that's still too inconvenient I believe the CallJS plugin has a property to set an external javascript file. So that could likely be used to include any script and you wouldn't need a custom plugin just to include a specific one.

    EDIT: If you use a plugin dependency to include a javascript file, the tag to include the file will not be placed in the head of the index.html file.

    This can become relevant, because some APIs demand that the script be included in the head tag of the html document. I had the case that my implementation got rejected simply because the reference to the script wasn't within the head tag.

    However the spilgames API documentation just recommends to put it in the head, so you should be fine in this case. I still thought I'd mention this odd thing. <img src="smileys/smiley12.gif" border="0" align="middle" />

  • You can also create a simple plugin with no functions. Which sole job is to insert the custom api into window.foo name space. Then he wouldn't even need to modify anything else. So why not that. Even makes it easier in the long run. Also some wrappers don't even use the index.html.

    I can't say he is using CJS, more than likely it's just for a web browser. But if say it were CJS. Then putting the modifcation in index.html would have no effect as index.html isn't being used.

    Ah, I see where you're coming from. I suppose you could also easily include an external js script by adding the CallJS plugin, which has a property to do so.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey PixelRebirth

    I have tried something like that >

    I added those in index.html

    <script type="text/javascript"

    src="http://cdn.gameplayer.io/api/js/game.js"></script> ( before </head>)

    and

    <script>

         //Spil Api

         GameAPI.loadAPI(function(API) {

    GameAPI.GameBreak.request(fnPause, fnResume);

    });

    var apiTry= 2;

    function fnPause()

    {

    var apiTry = 0;

    }

    function fnResume()

    {

    var apiTry = 1;

    }

    </script> (after <script src="c2runtime.js"></script> )

    Also I have added those in capx.

    <img src="http://new.tinygrab.com/bd08b53d3f72a32d77a05e99619f2c09321047a8e2.png" border="0" />

    After all there is no error in console and when I tried apiTry = 0 and apiTry=1 it works. But there is no ads or anything.

    Just wanted to mention that in your script you keep declaring the variable apiTry every time. Actually it should just say "apiTry=value;" when you want to change it again. You only have to put "var apiTry=value;" one time.

    Also I'm not sure if you just did this for testing purposes, but I noticed you put "GameAPI.GameBreak.request(fnPause, fnResume);" in the loadAPI method. Normally you should call this from within C2 whenever you want to show an ad and not when the API is readily loaded.

    I also made a similar test on my localhost and didn't get any javascript errors either. And no ad either. I observed that you only ever get the fnResume callback, never fnPause, but this might be because it was on localhost. Also the branding thing seems to return "0" every time.

    This might be because the game has to be on their platform servers to work. I've used a couple of APIs before and usually they have some sort of online testing environment, it wouldn't work locally. Some do have a special script for testing locally too, which is nice.

    I really don't know about spilgames. Registering with them as a developer just gives you access to flash related stuff. Including such an online tester.

    Probably just wait for what skyhunter93 will report. <img src="smileys/smiley4.gif" border="0" align="middle" />

  • c2runtime.js

    at the very top or bottom(before or after C2 closure) insert the API code chunk. Make sure it's part of the window.[foo name space]

    then in C2

    Browser.execJS( api.function_name )

    You will need to insert this custom JS code into the c2runtime every time.

    Any particular reason why you suggest to put the code in the runtime file?

    Having it in the index.html should work just as well. Also you simply could keep a separate index file in the export folder without the need to always inject the script anew after exporting.

  • Holy cow, I was actually already contacted earlier by skyhunter93, but I kind of forgot all about it. <img src="smileys/smiley9.gif" border="0" align="middle" />

    We had a brief exchange over Skype and he said he was about to realize the implementation himself. I hope he succeeded in the meantime and would be so kind to share his approach.

    I think the problem was with the request(fnPause, fnResume) method. You need to define the functions fnPause and fnResume yourself and have them pause and resume the C2 game.

    A way to do this would be to create these functions in an additional js file or in a script tag in the index.html itself. Make them simple functions that change a variable, also defined in the same js file/script.

    Now in Construct you can actually compare the value of this variable with the Browser.ExecJS() expression. Just put "variablename" there. And obviously use it in a Compare two values condition of the System object.

    I imagine that should work, keep asking if there's anything yet unclear.

    I do believe skyhunter93 was creating a plugin btw, which could be ready by now. Don't see him on Skype right now, but maybe he will come back to this thread.

  • Have received a PM about this API.

    From briefly looking at the documentation I think this should be indeed possible with execute javascript and a little editing of the index.html file.

    Will look further into it as soon as possible and let you know.

  • If I understand this correctly, using the execute javascript action of the browser object should do the trick. Have you tried that already?

  • PixelRebirth

    But wouldn't you just be linking the player to this URL if not edited?

    "http://moregames.differencegames.com"

    But then again I guess FGL would decline the game if we did edit the file.

    Yes, sure. I don't know if that's a placeholder URL and FGL will replace it, in which case it probably wouldn't matter if you edited it first.

    It should end up linking to their crosspromotion system somehow, so editing the URL doesn't make sense anyway, because this function is not for linking to your own site or a site of your choice. As I understand it of course. <img src="smileys/smiley2.gif" border="0" align="middle" />

    Also it might not be such a good idea to send your direct html5 export to fgl. I'm not claiming that they steal or anything but I think it might be best to have your scripts obfuscated so sponsors or companies would have a harder time to steal and edit the game. Since minify doesn't work I guess i'll have to manually edit my scripts so they look like a bunch of jargon. Unless someone can fix the minifying issue with the fgl plugin.

    Any takers?

    Why use the plugin at all? You can minify just fine with the way I described earlier (use the execute javascript action of the browser object). Any problems for you with that method?

PixelRebirth's avatar

PixelRebirth

Member since 26 Mar, 2008

Twitter
PixelRebirth has 1 followers

Trophy Case

  • 16-Year Club
  • Entrepreneur Sold something in the asset store
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

23/44
How to earn trophies