Pode's Forum Posts

  • Kyatric : yes, same disease as yours ;)

    Thanks for the help.

  • Kyatric : it's my fault, I realized the plugin used is the old version (http://dl.dropbox.com/u/31151399/Construct2/Plugins/randomArray_old.zip) of RandomArray. I remember I kept that one, because I can use the "CurValue", which is missing from the new version).

    (Something completely unrelated. I saw that you are in France, but I don't remember where I saw that, are you french yourself ?)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound: is it possible to add a function to you Canvas plugin to retrieve the canvas' image as data (I think the best is to retrieve a base64 text string) ?

    I'm trying to add a property inside the canvas object, but it doesn't works...

    (In fact, I'm trying to implement a floodfill like there http://www.williammalone.com/articles/html5-canvas-javascript-paint-bucket-tool/, but perhaps I'm trying to climb a too high mountain...

  • Here is the capx of a Fifteen game I made (the tiles are a bit small, but they are going to be replaced by a larger image at the end).

    Fifteen Game capx

    And here's the screenshot : <img src="http://dl.dropbox.com/u/1412774/15pb.png" border="0">

    (By the way, I'm using the Random Array plugin)

    As you can see, the logic I tried to make to switch between tiles is a bit strange, since at the time I didn't want to use a second array to store the game. In fact, I store the properties of the tile I clicked on, I move the mouse with the left button pressed, and I store the properties of the tile I lifted my finger on. If the two are a tile next to the empty spot, the move is "valid". With that, I have the problem that I can jump across the board, if the destination spot is the empy spot...

    Right now, I have two more problems : the first one (which is minor and doesn't bother me if I can't do it another way) is that I want to slide the tile with the mouse, without going outside the grid, and without allowing collision without another Sprite (just letting the player go to the empty spot with his selected tile). For the moment, there is no "sliding" movement. I validate the tile switch after the gesture, and there is nothing "dynamic". Anyway, it's just a cosmetic problem so it's not the biggest one.

    The other problem is that I want a "victory" condition. For that, I need to know if the tiles are in the right order. Since I don't use an array (and using an array seems difficult for me in that context of "sliding" tiles), I need to find a quick trick to do that.

    One of my idea was to use an invisible "growing bar" on the left of the game, which count the tile it intersect at each tick, and if the order of those tiles is the right one (i.e. "1", "2", "3", and "4"), then that row is good ! Repeat that for the 4 rows, and we have a victory condition...

    In the end, I think that all my code is overly complicated and that the victory condition can be made simpler. Does anybody have an idea ?

  • I wanted to have the possibility to click on something, and while the button isn't released, that the object follow the mouse, but only allong one of the two axis (i.e. when you go to the left or right, the object only slides allong the X axis, and vice-versa).

    I needed that kind of behavior for a game, and since there is no pre-made behavior for that, here's a solution : capx

  • You can't draw SVG inside an HTML5 canvas. One solution would be to use an hidden SVG context as a plugin, and dump the drawing done on that SVG context in a PNG, which is then pasted inside C2's canvas...

  • Ashley: My bad ! Why do it the easy way when you can do it the hard way ? ;) (I didn't saw the accelerometer in that object before, by lack of use for it for the moment...)

  • Quick response (I only have 2 minutes right now) : you can put the javascript to access the acceleromter in its own function, inside the exported index.html. Then you can use the CallJS plugin to call that function, and update the various items you are drawing with the information from the accelerometer.

  • Lprez: sadly, you can't play two sounds simultaneously, even with that method.

    : I tried to play wave file over an already playing audio background (tried with an .mp3 and a .mp4 on the ipad), and it doesn't work (I remember one of your comment saying that perhaps you would try wav SFX on top of compressed audio background). From my experience, it doesn't work, but I can be wrong in implementing that hack.

    I also tried some javascript libs to generate wave audio data (like riffwave.js), it doesn't work either. And Mobile Safari doesn't want to play a wave or an mp3 base64-coded dinamically inserted into the DOM.

    So I think we need to wait for Apple to change that on their browser, or find a XCode Project that uses a UIWebView and some tricks to bind the JS audio calls to some native code...

  • Same thing for me...

    Edit : correction - the board said yesterday that I have it, and today it's gone.

  • Ashley: I think you are right. By checking quickly the samples on the site of Impact JS, I saw that you need to call specific CSS tags and JS stuff for the ImpactJS framework to do its magic (I suppose that for the OpenGL/OpenAL layer to find its eggs, it's the sensible thing to do).

    So I'm going to investigate the AppMobi route.

  • Sorry to bring back from the dead that old thread.

    I was thinking about the fact that ImpacTJS doesn't use a UIWebView, but was translating JS to an OpenGL/OpenAL underlying engine.

    Since we have a problem with HTML5 audio on iOS (impossible to have two sounds playing simultaneously), does somebody knows if it's possible to bypass that limit by running the C2 export through ImpactJS ?

    Does somebody already tried to run the exported index.html through that engine ?

  • Lprez: you can use the solution I present I the main C2 section of the forum.

  • R0J0hound: I just noticed that if you want pixels added in realtime to the canvas when drawing with the mouse, you need to "force refresh" on the canvas. To do that, I use two actions consequently (i.e SetInvisible by SetVisible). Apart from that, everything is great !

  • I needed html5 audio on ios 5 (ipad exactly) for a client. Since the audio support on MobileSafari and UIWebView is somewhat sketchy, it was impossible to certify a sound playing on touch without lag (or sometime no sound at all).

    Here's the limitation for the audio tag on iOS5 (and previous) : you can't initiate (preload or play) a sound without a user interaction first. Even after that, you can't be sure when the audio file is going to be loaded or streamed, and you don't know when it's going to stop. Furthermore, no possibility to play several sounds mixed together.

    I then remembered of the concept of "audio sprites". You load a sprite consisting of all your SFX pasted in a unique file, and then you move the head along the file when you need to play a specific sound.

    I found two implementations for Javascript (https://github.com/koggdal/AudioSprite & remysharp.com/2010/12/23/audio-sprites/), and chose the first one.

    Here's the demo http://dl.dropbox.com/u/1412774/AudioSpriteExample/index.html (you're not going to hear any sound if you are not using an ipad or an iphone to access it...). I tested it against iOS 4.X & iOS 5.

    Since I don't have access to the core C2 script (and injecting something inside the prettyfied minified JS is not something I can handle without breaking things), I added the JS file inside the HTML page exported by Construct.

    So you need to :

    1) put http://dl.dropbox.com/u/1412774/AudioSpriteExample/audiosprite2.js inside your exported game folder, next to your index.html

    2) concatenate all you audio SFX inside a single audio file. Put blank audio part between your sounds, and make a quick note of the starting and ending timing for each one of them (in milliseconds. You can use something like Audacity).

    3) put a file like http://dl.dropbox.com/u/1412774/AudioSpriteExample/audiomodif.js at the root, and modify it to reflect you audio structure.

    In the create function, you need to add the number of samples, and their timing.

    function create(){

         sprite = new AudioSprite("audiosprite.mp3", [ { start: 50, length: 450 }, { start: 800, length: 900 }, { start: 1601, length: 2200 } ])

         sound1 = new Sound(sprite, 0);

         sound2 = new Sound(sprite, 1);

         sound3 = new Sound(sprite, 2);

    }

    Don't forget to add a var and a function to play each of those sounds !

    var sound4;

    function play4(){

         sound4.play();

    }

    4) By using the wonderful CallJS plugin (http://www.scirra.com/forum/plugin-call-javascript_topic45866.html), you can bind the create() and play() functions of your external JS to actions inside your C2 game.

    4.1) Since it's a limitation of iOS, you need to start the sound loading by initiating a user action. I "force" him to click on something on screen, and bind that action the the create() function with CallJS (you can see the example here http://dl.dropbox.com/u/1412774/AudioSpriteExample/AudioSpriteExample.capx).

    4.2) I attach the various "playX()" calls to the various objects inside my C2 scene.

    And.... DONE !

    Some caveats, though : you can only play one sound at a time with JS on iOS (it steams from the fact that javascript can only send one sound buffer at a time to the decoder, and can't premix those buffers). So you're not going to be able to play a background music and sound SFX on top of that.

    Before yelling that is doesn't work, check the file format you are using oin the platform for your concatenated sound (.mp3/.m4a and not .ogg for iOS), and double check that the embedded url inside your JS file reflect that.